Saturday, May 14, 2011

c program for file copying

#include
main()
{
FILE *f1,*f2;//FILE is a defined data type under stdio.h
char c;
f1=fopen("Input","r");
f2=fopen("Inputcopy","w"); /*Open the file Input, Creates or opens a file*/
while((c=getc(f1))!=EOF) /*get a character from key board until cntrl+z is pressed*/
{
putc(c,f2);
printf("Copying %c to file\n",c);/*write a character to input*/
}
fclose(f1);
fclose(f2); /*close the file input*/
system("pause");
}

No comments:

Post a Comment