Tuesday, August 12, 2014

Program to copy a file

C program to copy file. If you have any doubts, let me know

#include <stdlib.h>
#include <stdio.h>
main()
{
   
FILE *source, *target;
char x, sourcef[100], targetf[100];
printf("File to copy?"); gets(sourcef);   source=fopen(sourcef, "r");  printf("Target File?"); gets(targetf);   target=fopen(targetf, "w");   while((x=fgetc(source))!=EOF) fputc(x, target);   printf("The file has been copied."); }

No comments:

Post a Comment