(d) Write a program to copy the file contents of file1 to another file, file2.
write the complete program using files concept of C programming
Answers
Answered by
2
Answer:
int main()
{
char ch, source_file[20], target_file[20];
FILE *source, *target;
printf("Enter name of file to copy\n");
gets(source_file);
source = fopen(source_file, "r");
printf("Enter name of target file\n");
gets(target_file);
target = fopen(target_file, "w");
while ((ch = fgetc(source)) != EOF)
fputc(ch, target);
printf("File copied successfully.\n");
fclose(source);
fclose(target);
return 0;
}
Similar questions