Please use these tags to separate your code:
http://www.cplusplus.com/articles/z13hAqkS/
-It makes it easier to read and I can play with the code to adjust things to better explain.
Are you getting an error? If you are those will help us help you. Another reason I ask is because your syntax looks wrong in a few places.
1 2
|
fstream inputFile; // ifstream is for files you will read in.
fstream outputFile; // ofstream is for files that will store the out going data.
|
ifstream and ofstream are file stream variables
1 2 3
|
//Explained above
ifstream variable;
ofstream variable;
|
1 2
|
//Open the file in input mode.
inputFile.open("plain.txt", ios::in);
|
Not sure if the( ios::in ) is necessary; but the following should work :
inputFile.open("fileName.txt");
Another option:
|
inputFile.open(file_Name.c_str());
|
//Note that the file_Name can be a string variable that the user defines.
Also it might be easier to control the loop with a do while rather than an if this then while this..
For Example:
1 2 3 4 5 6
|
do{
inputFile.open("fileName.txt");
}while(!inputFile.is_open());//notice the explanation point in the condition...
getline(inputFile, input);
|
You kinda lost me here, buddy. I would think that an int would suffice. i < input.length() "
might" work better.
If someone else see's this and agrees or disagrees I would like to hear which would be better.
- Please read comments next to variables and please explain.
1 2 3 4 5 6 7
|
for (size_t i = 0; i < input.size(); ++i)
{
input[i] += 4;//Adding 4 to the ASII value each character
int input; //This does not make since to me. Is this suppose to be a static cast?
ch = input; /* Im confused here but maybe its just me... */
outputFile.put(ch);
}
|
Hope this helps, let me know if this does not work or does not help and Ill take another look.