Friday 7 September 2012

copying a file by converting all letters to upper case

#include <stdio.h>
#include <conio.h>
#include <string.h>

void main(void)
{
    FILE *fp1,*fp2;
    char st[125];

    clrscr();
    printf("Program for Copying a File by converting "
        "\n all Letters to Uppercase Letters\n");
    fp1 = fopen("file4.c","rb");
    if (fp1 == NULL)
      {
        printf("File Opening Error\n");
        exit(0);
      }
    fp2 = fopen("four.dat","wb");
    if (fp2 == NULL)
      {
        printf("File Opening Error\n");
        exit(0);
      }
    printf("\nThe file \"file4.c\" is opened and copied onto "
        "\n\"four.dat\" by converting all letters "
            "to Uppercase Letters\n");
    while (!feof(fp1))
       {
        fgets(st,120,fp1);
        strupr(st);
        fputs(st,fp2);
       }
    fcloseall();
    printf("\nPress any key to end...");
    getch();
}

No comments:

Post a Comment