VC++中没,那为什么_getch需要这个头文件呢
VC++中没有<conio.h>这个头文件吧,Cstdio可以从MSDN查得到,
Defines the macros traditionally defined in the Standard C library header <stdio.h>.
#if <TRADITIONAL C HEADERS>
#include <stdio.h>
namespace std {
using ::fclose;
using ::feof;
using ::ferror;
using ::fflush;
using ::fgetc;
using ::fgetpos;
using ::fgets;
using ::FILE;
using ::clearerr;
using ::fopen;
using ::fprintf;
using ::fpos_t;
using ::fputc;
using ::fputs;
using ::fread;
using ::freopen;
using ::fscanf;
using ::fseek;
using ::fsetpos;
using ::ftell;
using ::fwrite;
using ::getc;
using ::getchar;
using ::gets;
using ::perror;
using ::putc;
using ::putchar;
using ::printf;
using ::puts;
using ::remove;
using ::rename;
using ::rewind;
using ::scanf;
using ::setbuf;
using ::setvbuf;
using ::size_t;
using ::sprintf;
using ::sscanf;
using ::tmpfile;
using ::tmpnam;
using ::ungetc;
using ::vfprintf;
using ::vprintf;
using ::vsprintf;
}
#endif
Remarks
Including this header also ensures that the names declared with external linkage in the Standard C library header are declared in the std namespace. In this implementation, the names may or may not also be declared in the global namespace, depending on the specific translation environment.
VC++里面没有<conio.h>这个东西,我又查了下_getch,它 又包含在conio.h里,这是为什么呢.
下面是从MSDN查到的有关_getch
This POSIX function is deprecated beginning in Visual C++ 2005. Use the ISO C++ conformant _getch instead.
Gets a character from the console without echo.
int _getch( void );
wint_t _getwch( void );
Return Value
Returns the character read. There is no error return.
Remarks
The _getch and _getwch functions read a single character from the console without echoing the character. None of these functions can be used to read CTRL+C. When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code.
These functions lock the calling thread and are therefore thread-safe. For non-locking versions, see _getch_nolock, _getwch_nolock.
Generic-Text Routine Mappings
Tchar.h routine _UNICODE and _MBCS not defined _MBCS defined _UNICODE defined
_gettch
_getch
_getch
_getwch
Requirements
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
Example
Copy Code
// crt_getch.c
// compile with: /c
// This program reads characters from
// the keyboard until it receives a 'Y' or 'y'.
#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
}