Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- FILE *fp,*fp2;
- int p;
- char *filename;
- // printf("enter the file name from which you have to remove the extra blank spaces: ");
- // scanf("%s",filename);
- // printf("%s",filename);
- fp=fopen("input.txt","r");
- fp2=fopen("newfile.txt","w"); //all the content gets copied to this filename and extra blank spaces are also removed from your file
- while((p=getc(fp))!=EOF)
- {
- fputc(p,fp2);
- if (p==32) // since the ascii code for a blank space is 32
- {
- while((p=getc(fp))==32)
- {
- }
- fputc(p,fp2);
- }
- }
- fclose(fp);
- fclose(fp2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement