I am attempting to write some code that will take an input secret message and decode it by taking the character - 3, displaying the message in the output. I believe the rest of my code is okay, but what is wrong with my SetText and GetText functions/calling/I don't know? When I run my program, the output is as follows:
The original text in decodeme.txt is:
Using the ASCII value conversions, the decoded message is:
I’m afraid the rest of your code is betraying you ;-)
There’re other issues, but the first one is your code doesn’t read your file, since it’s not being properly opened.
You open it here: ifstream inFS("decodeme.txt");
and then you try to open it again in the following line: inFS.open("decodeme.txt");
Return value
this on success, a null pointer on failure.
You don’t catch the error because you look for only a few of them, not all of them. To control every stream error condition you can check directly their state, in this case: if ( ! inFS )
instead of if (!inFS.is_open())
I don’t want to give you further advice because I don’t want to spoil your fun, but feel free to ask again if you’re unsatisfied with your code.