Console and Port I/O

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see Console and Port I-O on docs.microsoft.com. These routines read and write on your console or on the specified port. The console I/O routines are not compatible with stream I/O or low-level I/O library routines. The console or port does not have to be opened or closed before I/O is performed, so there are no open or close routines in this category. In the Windows operating systems, the output from these functions is always directed to the console and cannot be redirected.

Console and Port I/O Routines

RoutineUse
_cgets, _cgetws, _cgets_s, _cgetws_sRead string from console
_cprintf, _cwprintf, _cprintf_s, _cprintf_s_l, _cwprintf_s, _cwprintf_s_lWrite formatted data to console
_cputsWrite string to console
_cscanf, _cwscanf, _cscanf_s, _cscanf_s_l, _cwscanf_s, _cwscanf_s_lRead formatted data from console
_getch, _getwchRead character from console
_getche, _getwcheRead character from console and echo it
_inpRead one byte from specified I/O port
_inpdRead double word from specified I/O port
_inpwRead 2-byte word from specified I/O port
_kbhitCheck for keystroke at console; use before attempting to read from console
_outpWrite one byte to specified I/O port
_outpdWrite double word to specified I/O port
_outpwWrite word to specified I/O port
_putch, _putwchWrite character to console
_ungetch, _ungetwch"Unget" last character read from console so it becomes next character read

Input and Output
Run-Time Routines by Category

Show: