_getch() doesnt work for me

Q

Quakegamer28

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!
 
J

Jonathan Mcdougall

Uhm, Im using Dev-C++.

So what?
Source looks like this

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

#include <conio.h>

Non standard.
#include <ctype.h>

Prefer c++ headers :

# include said:
void main( void )

Yurk. Illegal

int main()
{
int ch;

_cputs( "Type 'Y' when finished typing keys: " );

What is _cputs()?
do
{
ch = _getch();

What is _getch()?
ch = toupper( ch );
} while( ch != 'Y' );

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

What is _putch()?
}

HELP HELP HELP!

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

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


Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top