_putch

Writes a character to the console.

int _putch( int c );

Routine Required Header Compatibility
_putch <conio.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

The function returns c if successful, and EOF if not.

Parameter

c

Character to be output

Remarks

The _putch function writes the character c directly (without buffering) to the console.

Example

/* 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       */
}

Output

Type 'Y' when finished typing keys: Y

Console and Port I/O Routines

See Also   _cprintf, _getch