Lowercase to Uppercase, Vive-versa File Handling coderinme

Lowercase to Uppercase, Vive-versa File Handling coderinme

Lowercase to Uppercase, Vive-versa File Handling coderinme
Now, let us the user give a string in the input file with a combination of uppercase and lowercase letters, we need to convert all the uppercase characters into its repective lowercase and vice-versa

Write a program that reads a file and converts the alphabets upper case to into lower case and vice-versa. Store the result in new file and display the result (file name “c:\\result.txt”).

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
FILE *myfile,*outfile;
char c;
myfile = fopen("input.txt", "r");
outfile=fopen("result.txt","w");
if (myfile == NULL)
{
printf("File doesn't exist\n");
getch();
exit(0);
}
else
{
do
{
c = fgetc(myfile);
if(islower(c))
c =(char)toupper(c);
else
c =(char)tolower(c);
fprintf(outfile,"%c",c);
putchar(c);
}
while (c != EOF);
}
fclose(myfile);
getch();
return 0;
}

For more programs in C, visit our C Coder Archives

Lowercase to Uppercase, Vive-versa File Handling coderinme

Lowercase to Uppercase, Vive-versa File Handling coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.