Advertisement
mhdew

space removal

Mar 27th, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     FILE *f1, *f2;
  6.     f1=fopen("in.txt", "r");
  7.     f2=fopen("out.txt", "w");
  8.  
  9.     int f=0;
  10.     char c;
  11.     while((c=fgetc(f1))!=EOF){
  12.         if(c==' '){
  13.             if(f==0){
  14.                 fputc(c,f2);
  15.                 f=1;
  16.             }
  17.         }
  18.         else{
  19.             f=0;
  20.             fputc(c,f2);
  21.         }
  22.     }
  23.  
  24.     fprintf(f2,"\n");
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement