// crt_gets.c
// compile with: /W1
#include
int main( void )
{
char line[21]; // room for 20 chars + '\0'
gets( line ); // C4996
// Danger: No way to limit input to 20 chars.
// Consider using gets_s instead.
printf( "The line entered was: %s\n", line );
}
Note that input longer than 20 characters will overrun the line buffer and almost certainly cause the program to crash.
是不是你的gets用错了??
Input
Hello there!
Output
The line entered was: Hello there!
详情回复
发表于 2008-4-29 09:57
int main( void )
{
char line[21]; // room for 20 chars + '\0'
gets( line ); // C4996
// Danger: No way to limit input to 20 chars.
// Consider using gets_s instead.
printf( "The line entered was: %s\n", line );
}
Note that input longer than 20 characters will overrun the line buffer and almost certainly cause the program to crash.
是不是你的gets用错了??