Wednesday 18 December 2013

C Program to Replace all the Characters by Lowercase

#include < stdio.h>
#include < stdlib.h>
 
void main(int argc, char* argv[])
{
    FILE *fp1;
    int ch;
 
    if ((fp1 = fopen(argv[1], "r+" )) == NULL)
    {
        printf("\nfile cant be opened" );
        exit(0);
    }
    ch = fgetc(fp1);
    while (ch != EOF)
    {
        if (ch >= 65 && ch <= 90)
        {
            fseek(fp1, -1L, 1);
            fputc(ch + 32, fp1);
        }
        ch = fgetc(fp1);
    }
}

Output

 file4test
   cat  file4test
chandana chanikya
ravella

For More Details Please Visit Ictjobs.info

No comments: