Skip to main content

File Copy to another File in C

 



#include <stdio.h>
int main()
{
    FILE *a, *b;
    int c;
    a = fopen("myfile.txt", "r");
    b = fopen("text.txt", "w");
    while ((c = fgetc(a)) != EOF)
    {
        fputc(c, b);
    }
    printf("\nFile Copied\n\n");

    fclose(a);
    fclose(b);

    return 0;
}

Comments