Advertisement
Anna3O0

Lab3

Nov 26th, 2022
996
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. // Collapse spaces
  2.  
  3. #include <stdio.h>
  4. #include <ctype.h>
  5.  
  6. int main()
  7. {
  8.  
  9.     int c;
  10.     while((c=getchar())!=EOF)
  11.     {
  12.         if(c==' ')
  13.         {
  14.             while(isspace(c=getchar()));
  15.  
  16.             if(c!='\n')
  17.                 putchar(' ');
  18.             putchar(c);
  19.         }
  20.         else
  21.             putchar(c);
  22.     }
  23.     return 0;
  24. }
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement