I have an assignment that asks:
Write a C++ program that reads text from a file and decodes the file by subtracting 5 from the ASCII value of each character.
1. Read the text file one line at a time.
2. Change each character of the string by subtracting 5 from it.
3. Write the encoded string to a second file, such as plain.txt
So far, I have this:
using namespace std;
inputPlain >> linNum;
outputPlain << encodedLine << endl;
it works, except that it repeats the last line of code twice. I need to read it to read the line, then check for the end of the file before processing. Any help would be greatly appreciated.
Just read the data inside the while() statement:
while ( inputPlain >> linNum )
Oh wow, that was a simple fix. Thanks for the help!