多格空格用一个空格替换

#include <stdio.h>

main()
{
      int c,lastc;
      
      while((c = getchar()) != EOF){
               if (c != ' ')
                 putchar(c);
               if (c == ' ')
                if (lastc != ' ')
                   putchar(c);
             lastc = c;
      }
}

getchar函数用户输入的字符被存放在键盘缓冲区中.

posted @ 2016-12-20 20:23  暮雪超霸  阅读(200)  评论(0)    收藏  举报