Connecting Tech Pros Worldwide Help | Site Map

_getch() doesnt work for me

  #1  
Old July 19th, 2005, 07:47 PM
Quakegamer28
Guest
 
Posts: n/a
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!
  #2  
Old July 19th, 2005, 07:47 PM
Jonathan Mcdougall
Guest
 
Posts: n/a

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.

http://www.parashift.com/c++-faq-lite/how-to-post.html


Jonathan




Closed Thread