Advertisement
mhdew

ritu

Mar 27th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     FILE *fp,*fp2;
  7.     int p;
  8.     char *filename;
  9. //    printf("enter the file name from which you have to remove the extra blank spaces: ");
  10. //    scanf("%s",filename);
  11. //    printf("%s",filename);
  12.     fp=fopen("input.txt","r");
  13.     fp2=fopen("newfile.txt","w");  //all the content gets copied to this filename and extra blank spaces are also removed from your file
  14.  
  15.     while((p=getc(fp))!=EOF)
  16.     {
  17.  
  18.         fputc(p,fp2);
  19.         if (p==32) // since the ascii code for a blank space is 32
  20.         {
  21.             while((p=getc(fp))==32)
  22.             {
  23.             }
  24.             fputc(p,fp2);
  25.         }
  26.     }
  27.  
  28.     fclose(fp);
  29.     fclose(fp2);
  30.    
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement