#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
usingnamespace std;
int main()
{
ifstream inFile;
inFile.open("message.txt");
//Check to see if open
if (inFile.fail())
{
cout << "File cannot be opened" << endl;
exit(1);
}
char c;
while (inFile.get(c)) // loop getting single characters
cout << c;
inFile.close(); // close file
return 0;
}
So I am not looking for answers, just a little direction with reading and writing to a file. So I have successfully opened my file, and it reads it just fine. I am trying to rewrite the data in another file figuring out if the data is upper case or lower case, and rewriting it all in upper case. Just a little direction would help, thank you.
Basically you need to create a output file (ofstream) and in the loop where you read from the input you need to check if it is lower case then convert to upper case and write to the output file.
To convert to upper case you can use the toupper function, to check if is lower case you have to write your own function.