Connecting Tech Pros Worldwide Help | Site Map

_getch() doesnt work for me

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 19th, 2005, 06:47 PM
Quakegamer28
Guest
 
Posts: n/a
Default _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!

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




 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.