C LAB‎ > ‎(Sem1) Introduction to C‎ > ‎

WAP to copy the contents of one file to another.

posted Nov 18, 2010, 4:39 AM by Neil Mathew   [ updated Nov 18, 2010, 4:44 AM ]

SOURCE CODE:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
main()
{
         char ch;
 
     FILE *fp1, *fp2;
     fp1 = fopen("abc.txt", "r");
     fp2 = fopen("xyz.txt", "w");
 
     while((ch = getc(fp1)) != EOF)
          putc(ch, fp2);
 
     fclose(fp1);
     fclose(fp2);
     return 0;
}
 
Comments