Program 204:
//Coming Soon...
Output:
Store both text file and program in same folder.Here I named text file as file3append.txt
Running the Program
After Running the program
#include<stdio.h> #include<stdlib.h> main () { FILE *file; char c; file=fopen("file3append.txt","w"); fprintf(file,"%s","Hello!"); fclose(file); file=fopen("file3append.txt","r"); printf("After writing\n"); //To display after write operation to file while(1) { if(file==NULL) { printf("File Not Found\n"); exit(0); } else { c=fgetc(file); if(c==EOF) { break; } printf("%c",c); } } fclose(file); printf("\n"); file=fopen("file3append.txt","a");//opening file in append mode fprintf(file,"%s","World"); fclose(file); file=fopen("file3append.txt","r"); printf("After appending\n"); //To display after append operation to file while(1) { if(file==NULL) { printf("File Not Found\n"); exit(0); } else { c=fgetc(file); if(c==EOF) { break; } printf("%c",c); } } fclose(file); printf("\n"); }Explanation:
//Coming Soon...
Output:
Store both text file and program in same folder.Here I named text file as file3append.txt
Running the Program
After Running the program
No comments:
Post a Comment