Method 1:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
FILE *out, *in;
char ch[25];
clrscr();
in=fopen("drive:\\file.ext","r"); /*Any file THAT you wanna copy
out=fopen("drive:\\file2.ext","w"); /*New file WHERE data will be copy
while(fgets(ch,25,in)!=NULL)
{
printf("%s\n",ch);
fputs(ch,out);
}
fclose(out);
fclose(in);
getch();
}
METHOD 2:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
FILE *out, *in;
char ch[25];
clrscr();
in=fopen("drive:\\file.ext","r"); /*Any file THAT you wanna copy
out=fopen("drive:\\file2.ext","w"); /*New file WHERE data will be copy
while(fgets(ch,25,in)!=NULL)
{
fputs(ch,out);
}
printf("DONE! Press any key to exit.");
fclose(out);
fclose(in);
getch();
}
Bookmarks