Q:

Write a C Program to Convert text of File to LowerCase

0

Write a C Program to Convert text of File to LowerCase. Here’s a Simple Program to Convert text of File to LowerCase in C Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Below is the source code for C Program to Convert text of File to LowerCase which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :

/* C Program to Convert text of File to LowerCase  */

#include <stdio.h>
#include <errno.h>

int to_lower_file(FILE *);

int main()
{
    int op = -1;
    char ch;
    char * arrr = "C:\\Users\\acer\\Documents\\file2.txt";
    FILE *fp;
    if (fp = fopen(arrr, "r+"))
    {
        printf("FILE has been opened..!!!\n");
        op = to_lower_file(fp);
        printf(" %d \n", op);
        fclose(fp);
    }
    else
    {
        perror("Error Occured");
        printf(" %d\n ", op);
    }

    return 0;
}

int to_lower_file(FILE *f)
{
    int c;
    char ch;
    while ((ch = fgetc(f))!= EOF)
    {
        c = (int)ch;
        if (c >= 65 && c <= 90)
        {
            ch = ch + 32;
            fseek(f, -1L, 1);
            fputc(ch, f);
        }
    }
    return 0;
}

OUTPUT : :


/* C Program to Convert text of File to LowerCase  */


FILE has been opened..!!!
 0


INPUT IN FILE ::

"HELLO FRIENDS"

OUTPUT IN FILE ::

"hello friends"

Above is the source code for C Program to Convert text of File to LowerCase which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
<< Write a C Program to Count Lines,Blank Lines,Comme...