C Program To Convert The File Contents In Upper-case

How To Write a C Program To Convert The File Contents In Upper-case & Write Contents In A Output File and Check whether two files are identical or not in C Programming Language ?


Solution For C Program To Convert The File Contents In Upper-case & Write Contents In A Output File and Check whether two files are identical or not.:
#include<stdio.h>

int main()
{
    FILE *fp1, *fp2;
    int ch1, ch2;
    char fname1[40], fname2[40] ;

    printf("Enter name of first file :") ;
    gets(fname1);

    printf("Enter name of second file:");
    gets(fname2);

    fp1 = fopen( fname1,  "r" );
    fp2 = fopen( fname2,  "r" ) ;

    if ( fp1 == NULL )
       {
       printf("Cannot open %s for reading ", fname1 );
       exit(1);
       }
    else if (fp2 == NULL)
       {
       printf("Cannot open %s for reading ", fname2 );
       exit(1);
       }
    else
       {
       ch1  =  getc( fp1 ) ;
       ch2  =  getc( fp2 ) ;

       while( (ch1!=EOF) && (ch2!=EOF) && (ch1 == ch2))
        {
            ch1 = getc(fp1);
            ch2 = getc(fp2) ;
        }

        if (ch1 == ch2)
            printf("Files are identical n");
        else if (ch1 !=  ch2)
            printf("Files are Not identical n");

        fclose ( fp1 );
        fclose ( fp2 );
       }
return(0);
 }
Tags: C Program To Convert The File Contents In Upper-case, c program to convert uppercase to lowercase by using file, c program to convert lowercase to uppercase using function, c program to convert lowercase to uppercase using pointers, c program to convert lowercase to uppercase and vice versa, c program to convert lowercase to uppercase without using string function, write a c program to convert lowercase to uppercase, convert lowercase to uppercase in c program, c program to count no of lines, blank lines, comments in a given program.


Learn More :