Formatted Input/Output in C for Programming Contest

In programming contest we have to use file to read data in different format and sometimes we have to write the output in a file. So, we have to know how to read from file. Here is the simple way to read from file and write as it in the another file.

    #include<stdio.h>

    void main()
    {
    FILE *fin,*fout;
    char c;
    fin=fopen("test.in","rb");
    fout=fopen("test.out","w");

    while(!feof(fin))
         {
            fscanf(fin,"%c",&c);
            fprintf(fout,"%c",c);
         }
    fclose(fin);
    fclose(fout);
    }

In this tutorial, I tried to brief formatted input/output in C++. Hope you have enjoyed the tutorial. If you want to get updated, like the facebook page https://www.facebook.com/freetechtectrainer and stay connected.

Add a Comment