Tuesday, 23 June 2015

WRITE A C PROGRAM TO COPY THE FILE.REPLACE ALL LOWERCASE CHARACTERS IN SOURCE FILE TO UPPER CASE CHARACTERS IN DESTINATION FILE



#include<stdio.h>
main()
{
    FILE *fs,*fd;
    char ch;
    fs=fopen("Hello.c","r");
    if(fs==NULL)
    {
        printf("can't open source file");
        exit(1);
    }
    fd=fopen("deccan.txt","w");
    if(fd==NULL)
    {
        printf("can't open destination file");
        exit(2);
    }
    while(1)
    {
        ch=fgetc(fs);
        if(ch==EOF)
        {
            break;
        }
        fputc(toupper(ch),fd);
    }
    fclose(fs);
    fclose(fd);
}


OUTPUT
-------------------------------------------
NOTE: First create a file name as Hello.c