Writes a character to the console.
#include <conio.h> | Required only for function declarations |
int _putch( int c );
c | Character to be output |
The _putch function writes the character c directly (without buffering) to the console.
The function returns c if successful, and EOF if not.
Standards:None
16-Bit:DOS
32-Bit:DOS32X
/* 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 */
}
Type 'Y' when finished typing keys: Y