函数简介函数原型:
wchar_t *_cgetws(
wchar_t *buffer
);
函数功能:
从键盘读入字符串
相关函数:_cgets
所属库:
<conio.h> or <wchar.h>
程序示例下面的程序示例来自MSDN[1]
#include <conio.h>
#include <stdio.h>
#include <errno.h>
int main( void )
{
char buffer[83] = { 80 }; // Maximum characters in 1st byte
char *result;
printf( "Input line of text, followed by carriage return:
");
// Input a line of text:
result = _cgets( buffer ); // C4996
// Note: _cgets is deprecated; consider using _cgets_s
if (!result)
{
printf( "An error occurred reading from the console:"
" error code %d
", errno);
}
else
{
printf( "
Line length = %d
Text = %s
",
buffer[1], result );
}
}