File Manipulation in C++, is what I have so far ok?

Here is my code, I'm trying to allow the user to input a path to a text file. It reads it, stores it, allows the user to input more data INTO the stored file, and also display what is stored on the console in it's entirety:

void LoadTextFile()
{
string filePath;

cout << "Enter a file path:"\n;
cin >> filePath;

ifstream inFile(filePath);
while (inFile.peek() != EOF) {
string inLine;
getline(inFile, inLine);
cout << inLine << endl;
}
inFile.close();

return 0;
}

how do I refer to what is stored now in order to add to it and/or display it on the console?
You never stored anything -- you only read each line and echoed it to the console.

I suggest using a vector of string to store the content of the file.

Hope this helps.
Topic archived. No new replies allowed.