Ask a Question

write a c program to print the contents of a file

on 2016-06-07 15:05:39   by anita   on Information Technology  1 answers

Biprajit

on 2016-06-09 09:30:00  

#include #include FILE *fp1,*fp2; char c; void main() { clrscr(); printf("enter the text "); fp1 = fopen("abc.txt", "w"); while((c = getchar()) != EOF) putc(c, fp1); fclose(fp1); fp1 = fopen("abc.txt","r"); fp2=fopen("xyz.txt","w"); while(!feof(fp1)) { c = getc(fp1); putc(c,fp2); } fclose(fp1); fclose(fp2); printf("the copied data is "); fp2 = fopen("xyz.txt", "r"); while(!feof(fp2)) { c = getc(fp2); printf("%c", c); } getch(); }