Ok im making a program that allows you to open a text file in the cmd window, then it should allow you to find a word from what was inputted and change it to something different, but when i try it, it says something alongs the lines that the proigram was asked to execute in an unusual way and has crashed or something. What am i doing wrong?
The crash is on line 68. storeText.find(str2) returns std::string::npos which means that the sting was not found. Passing std::string::npos to replace will throw an exception because it's not a valid position. You need to check the return value of find before passing it to replace.
When you call getline(fileIn, storeText) storeText will get a new value. If the call to getline fails it will leave storeText empty. That means you have not acutally stored the file content anywhere. After the loop on line 42-44 storeText will always be empty so you are always passing an empty string to ::find.