函式簡介
函式原型:wint_t _getwch( void );
函式功能:類似於getch()
所屬庫:
Routine | Required header | COMPATIBILITY |
_getch | <conio.h> | Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 |
_getwch | <conio.h> or <wchar.h> | Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 |
相關函式:
Tchar.h routine | _UNICODE and _MBCS not defined | _MBCS defined | _UNICODE defined |
_gettch | _getch | _getch | _getwch |
備註:wint_t說明見於stdio.h
typedef unsigned short wchar_t;
typedef wchar_t wint_t;
由此可見wint_t即unsigned short
程式示例
#include <conio.h>
#include <ctype.h>
int 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
}