int main(int argc, char *argv[]){ char ch1, ch2; printf("Input the first character:"); // Line 1 scanf("%c", &ch1); printf("Input the second character:"); // Line 2 ch2 = getchar(); printf("ch1=%c, ASCII code = %d\n", ch1, ch1); printf("ch2=%c, ASCII code = %d\n", ch2, ch2); system("PAUSE"); return 0;}
Enter key (ASCII code 13)
\n (ASCII code 10)
\n
getchar()
(ch2 = getchar();
Enter key (13)
\n
fflush()
voidclear (void){ while ( getchar() != '\n' );}
getchar() != '\n'
'\n'
'\n'
海绵宝宝撒
眼眸繁星
心有法竹