TO MAKE A COPY OF FILE USING STANDARD I/O AND SYSTEM CALLS
#include<stdio.h>
#include<conio.h>
void main()
{
char c;
FILE *f1,*f2;
f1=fopen("hai.txt","w");
printf("\nEnter text & press ctrl+z at the end\n");
while((c=getchar())!=EOF)
putc(c,f1);
fclose(f1);
printf("\nThe contents of file are\n");
f1=fopen("hai.txt","r");
while((c=getc(f1))!=EOF)
putchar(c);
fclose(f1);
printf("\nThe contents of second file that are copy from first file are\n");
f2=fopen("hai.txt","r");
while((c=getc(f2))!=EOF)
putchar(c);
fclose(f2);
}
No comments:
Post a Comment