c语言中只读取输入的一行字符的首个字符
测试程序1:
#include <stdio.h> int main(void) { char ch; printf("please input an character: \n"); while((ch = getchar()) != '#') printf("xxx\n"); return 0; }

测试程序2
#include <stdio.h> int main(void) { char ch; printf("please input an character: \n"); while((ch = getchar()) != '#') { printf("xxx\n"); while(ch = getchar() != '\n') // 为什么起作用????? continue; } return 0; }


浙公网安备 33010602011771号