_getch() doesnt work for me

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Quakegamer28

    _getch() doesnt work for me

    Uhm, Im using Dev-C++.

    Source looks like this

    /* GETCH.C: This program reads characters from
    * the keyboard until it receives a 'Y' or 'y'.
    */

    #include <conio.h>
    #include <ctype.h>

    void main( void )
    {
    int ch;

    _cputs( "Type 'Y' when finished typing keys: " );
    do
    {
    ch = _getch();
    ch = toupper( ch );
    } while( ch != 'Y' );

    _putch( ch );
    _putch( '\r' ); /* Carriage return */
    _putch( '\n' ); /* Line feed */
    }

    HELP HELP HELP!
  • Jonathan Mcdougall

    #2
    Re: _getch() doesnt work for me

    > Uhm, Im using Dev-C++.

    So what?
    [color=blue]
    > Source looks like this
    >
    > /* GETCH.C: This program reads characters from
    > * the keyboard until it receives a 'Y' or 'y'.
    > */
    >
    > #include <conio.h>[/color]

    Non standard.
    [color=blue]
    > #include <ctype.h>[/color]

    Prefer c++ headers :

    # include <cctype>
    [color=blue]
    > void main( void )[/color]

    Yurk. Illegal

    int main()
    [color=blue]
    > {
    > int ch;
    >
    > _cputs( "Type 'Y' when finished typing keys: " );[/color]

    What is _cputs()?
    [color=blue]
    > do
    > {
    > ch = _getch();[/color]

    What is _getch()?
    [color=blue]
    > ch = toupper( ch );
    > } while( ch != 'Y' );
    >
    > _putch( ch );
    > _putch( '\r' ); /* Carriage return */
    > _putch( '\n' ); /* Line feed */[/color]

    What is _putch()?
    [color=blue]
    > }
    >
    > HELP HELP HELP![/color]

    Please! Please! Please! Post a real question about the real C++ standard.




    Jonathan




    Comment

    Working...