write a program to copy its input to its output, replace each string of one or more blanks by a single blank.

#include <stdio.h>

#define NONBLANK 'a'

/*replace string of blanks with a single blank    */
int main(void){
   int c, lastc;

   lastc =NONBLANK;
    while ((c =getchar()) != EOF){
         if (c != ' ')
            putchar(c);
         if (c == ' ')
             if(lastc != ' ')
                putchar(c);
          lastc = c;
    }
}

Leave a comment