Login to ask a question from Data Files

Write C program to copy contents of one file to another file.

include  

#include // For exit() 

void main() 

{ 

    FILE *fptr1, *fptr2; 

    char filename[100], c; 

    printf("Enter the filename to open for reading \n"); 

    scanf("%s", filename); 

    // Open one file for reading 

    fptr1 = fopen(filename, "r"); 

    if (fptr1 == NULL) 

    { 

        printf("Cannot open file %s \n", filename); 

        exit(0); 

    } 

    printf("Enter the filename to open for writing \n"); 

    scanf("%s", filename); 

    // Open another file for writing 

    fptr2 = fopen(filename, "w"); 

    if (fptr2 == NULL) 

    { 

        printf("Cannot open file %s \n", filename); 

        exit(0); 

....

Show More
Previous Question Next Question
🔗

Similar Questions

From Data Files · C programming

View All
WhatsApp