Hi,
So I am a little confused about why my program is running the way it is right now. I just made a helper function that looks for stop words, and if it does find one... it removes that stop word.
Well, the program seems to run through completely and take out every stop word, but for some reason once it gets to the end it throws a out_of_range error! Does anyone know why this might be? I have a feeling it is because it goes past the last line and that throws the error? but im not sure... any advice would be appreciated :)
here is my function:
//helper function that only outputs non helper words
string strStop(string str) {
string text;
ifstream file;
file.open("stop.txt");
while (getline(file, text)) {
while (str.find("text") != string::npos) {
str.replace(str.find(text), str.length(), "");
}
}
return str;
}```
and here is my error:
```terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::replace: __pos (which is 4294967295) > this->size() (which is 32)```
How do I fix this?
