the-c-programming-language/chapter01/ex09.c (330B)
1 // Exercise 1-rite a program to copy its input to its output, replacing 2 // each string of one or more blanks by a single blank. 3 4 #include <stdio.h> 5 6 int main( void ) 7 { 8 unsigned long bl; 9 bl = 0; 10 11 int c; 12 13 while((c = getchar()) != EOF) { 14 if(c == ' ') 15 bl++; 16 else 17 bl = 0; 18 19 if(bl <= 1) 20 putchar(c); 21 } 22 23 return 0; 24 }