你可以自己处理阿 #include <stdio.h>void main( void ) { char buffer[81]; int i, ch; printf( "Enter a line: " ); /* Read in single line from "stdin": */ for( i = 0; (i < 80) && ((ch = getchar()) != EOF) && (ch != '\n'); i++ ) buffer[i] = (char)ch; /* Terminate string with null character: */ buffer[i] = '\0'; printf( "%s\n", buffer ); } OutputEnter a line: This is a test This is a test
_getch, _getche Get a character from the console without echo (_getch) or with echo (_getche).
#include <stdio.h>void main( void )
{
char buffer[81];
int i, ch; printf( "Enter a line: " ); /* Read in single line from "stdin": */
for( i = 0; (i < 80) && ((ch = getchar()) != EOF)
&& (ch != '\n'); i++ )
buffer[i] = (char)ch; /* Terminate string with null character: */
buffer[i] = '\0';
printf( "%s\n", buffer );
}
OutputEnter a line: This is a test
This is a test
Get a character from the console without echo (_getch) or with echo (_getche).
这个可以