#include <stdio.h> main() { int c,lastc; while((c = getchar()) != EOF){ if (c != ' ') putchar(c); if (c == ' ') if (lastc != ' ') putchar(c); lastc = c; } }
getchar函数用户输入的字符被存放在键盘缓冲区中.