标签:
This is a standard function that gets a character from the stdin.
getch
This is a nonstandard function that gets a character from keyboard, does not echo to screen.
getche
This is a nonstandard function that gets a character from the keyboard, echoes to screen.
Use getchar if you want it to work on all compilers. Use getch or getche on a system that supports it when you want
keyboard input without pressing [Enter].And note that the return value of all three is int! You need this to properly check for EOF.
void main() { int i; char tmp[20]; for (i = 0; i<20; i++) { tmp[i] = _getch(); //关键点1 // tmp[i]=getchar(); // putchar ( ‘*‘ ) ; printf("%d=[%c]\n", i, tmp[i]); if (tmp[i] == ‘\r‘) { tmp[i] = ‘\0‘; //关键点2 break; } } }
‘\r‘ ,“shift+回车键” 就能输入手动换行符
标签:
原文地址:http://www.cnblogs.com/JHarden/p/5659733.html