In C++, I am trying to read through a file and store the strings from that file into a string in the program. This works great until I get to the last word, which is always stored twice.
ifstream inputStream;
string next = "";
string allMsg = "";
inputStream.open(fileName.c_str());
string x;
while (!inputStream.eof())
{
inputStream >> x;
next = next + " " + x;
}
cout << "The entire message, unparsed, is: " << next << endl;
Doing this adds the last word or int from the file I open to next. Any suggestions? Thanks!