Logic and examples of file handling in c laguage
c pattern | programs | source code C | File Handling programs | Free Source Code | comments
write the simple program for file handling
#include<stdio.h>//header files//
void main()
{ ///start of main//
FILE *f1,*f2,*f3; //pointers//
char c;
clrscr(); // clear the screen//
printf("input text");
f1=fopen("cmb.txt","w"); //open file//
f2=fopen("cmb01.txt","w");
f3=fopen("cmb02.txt","a");
while((c=getchar()) != EOF)
putc(c,f1); //copy from one to another//
f1=fopen("cmb.txt","r");
while((c=getc(f1)) !=EOF)
printf("%c",c);
fclose(f1);
while((c=getchar()) != EOF) // use while loop for condition//
putc(c,f2);
fclose(f2);
f2=fopen("cmb01.txt","r");
while((c=getc(f2)) !=EOF) //till not end of file//
printf("%c",c); // print all the data//
fclose(f1); //close the file//
fclose(f2);
Share This
0 comments: