Hey Narue!
I need ur help on a upper-lower case switch problem..
Read the contents of a text file (using ifstream class)..
and create a new file or edit the same one (using ofstream class)
to switch the case of each char (upper to lower & vice versa)..
Thanks a bunch in advance
below is the code i tried but not working:
#include<iostream>
#include<fstream>
#include<cctype>
using namespace std;
int main()
{
ofstream lang("Batch6.txt");
lang<<"Pogram Name Shripal Parekh"<<endl;
lang<<"hELLO wORLD";
cout<<"File Created!\n";
lang.close();
ofstream newfile("SwitchedCases.txt");
ifstream rlang("Batch6.txt");
while(!rlang.eof())
{
char ch=rlang.get();
if(isalpha(ch))
{
if(islower(ch))
{
newfile<<(char)toupper(ch);
}
else
{
newfile<<(char)tolower(ch);
}
}
else
{
cout<<' ';
}
newfile.close();
}
return 0;
}