Transfer files

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:

#include <iostream>
#include <string>
#include <fstream>

using namespace std;
int main()
string encodedLine;
int CharNum;
string linNum;
fstream inputPlain;
fstream outputPlain;"plain.code", ios::in);"plain.txt", ios::out);

linNum ="";
while (inputPlain.good())
inputPlain >> linNum;
encodedLine ="";
CharNum =0;
while (CharNum<linNum.length())
CharNum =CharNum+1;
outputPlain << encodedLine << endl;
return 0;

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!
Topic archived. No new replies allowed.