you need to also upload your data file and edit this forum and mark all your coding than press <> button
and not sure why you would if(dataIn.is_open()) than did dataIn good.
if your data had one string like Monkey you sould print like
//read until blank
while(dataIn >> data)
{
cout << data << endl;
//Monkey
}
if two string than like Monkey Apple
while(dataIn >> data >> data2)
{
cout << data << data2 << endl;
// MonkeyApple
}
if you have data something like ... Monkey.Apple
than too long to explain....
" This is the first time I ever ate ice cream. I wish I was the first person who ever ate ice cream.
The very last time I ate ice cream, it gave me a headache. I swore it would be the last time.
All I ever do is eat, eat, eat ... all the time. We all eat too much all the time."
while (getline(namefile, Data))
{
// Data now has "This is the first time I ever ate ice cream. I wish I was the first person who ever ate ice cream." after finishing putting first setence, while loop move on to next setence. "The very last time I ate ice cream, it gave me a headache. I swore it would be the last time." for second
and goes untill data have nothing or empty sentence.
}
"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."
"Unhandled exception at 0x7697C42D in ConsoleApplication6.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0031F6E0."
Then I get a debug error saying "CRT detected the application wrote to memory before start of heap buffer."
These are not errors "when trying to compile." This is behavior exhibited when you run the compiled and linked code. Being accurate when describing your problem means anyone who responds is more likely to address the actual issue(s) you're having.
Your code doesn't make much sense. You continue overwriting the same string in the loop on lines 16 to 20. You do not check if the extraction was successful before doing anything with the string (and, in fact, on the last iteration of the loop it will not be successful.) After the loop you will either have only the last line in the file or an empty string.
std::string::replace requires a valid position argument. You don't make any effort to ensure you have one. std::string::find_last_of doesn't do what you think it does.
The while loop beginning on line 22 will never end.