Copy file content in C.

 

01  #include<stdio.h>
02
03 int main()
04 {
05 char c;
06 FILE *fp1,*fp2;
07
08 fp1=fopen("d:input.txt","w");
09 while((c=getchar())!=EOF)
10 putc(c,fp1);
11 fclose(fp1);
12
13 fp2=fopen("c:output.txt","w");
14 fp1=fopen("d:input.txt","r");
15
16 while ((c=getc(fp1))!=EOF)
17 putc(c,fp2);
18 fclose(fp1);
19 fclose(fp2);
20
21 fp2=fopen("c:output.txt","r");
22 printf("nnnn");
23
24 while((c=getc(fp2))!=EOF)
25 printf("%c",c);
26 fclose(fp2);
27 return 0;
28 }
 
  
OUTPUT :

Read content from file 'input.txt' and write it to the file named 'output.txt'

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.