I just dont understand this file thing at all. Can someone tell me what I am doing wrong? I am no good at this.
1.Read the text file one line at a time into a string.
2.Change each character of the string by adding 5 to it.
3.Write each encoded string to a second file, such as plain.code
4.The encodeed file should have the same structure as the original file, if the second line of the original file has 24 characters (including spaces) then there should be 24 characters on the second line of the encoded file.
insertCode:#include <iostream> #include <string> using namespace std; int main() { ifstream dataFile; cout << "Opening File....\n"; dataFile.open("plain.txt",ios::out); cout << "Now writing data to file.\n"; string s; cout << "Enter a string> "; if (!getline(cin, s)) { cerr << "Input failure" << endl; return 1; } for (string::size_type i = 0; i < s.length(); 5*i++) ++s[i]; cout << s <<endl; system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks



