25. write a C program to copy the data from one file to another.


Program to copy the data from one file to another.

Source Code:

#include<stdio.h>
void main()
{
FILE *fp,*fp1;
int ch;
fp=fopen("/home/smec/blank.txt","r");
fp1=fopen("/home/smec/bands_sorted.txt","w");
if(fp==NULL)
printf("File is not available");
ch=getc(fp);
while(ch!=EOF)
{
putc(ch,fp1);
ch=getc(fp);
}
fclose(fp);
fclose(fp1);
}

Output:

blank.txt







bands_sorted.txt



No comments:

Post a Comment