diff --git a/ch09/exercise9_43.cpp b/ch09/exercise9_43.cpp index 6d2e938..2405ea8 100644 --- a/ch09/exercise9_43.cpp +++ b/ch09/exercise9_43.cpp @@ -6,7 +6,7 @@ using namespace std; void replace(string& s, const string& oldVal, const string& newVal) { auto curr = s.begin(); - while (curr != s.end() - oldVal.size()) + while (curr <= s.end() - oldVal.size()) { if (oldVal == string(curr, curr + oldVal.size())) { @@ -28,4 +28,4 @@ int main() replace(s, "thru", "through"); cout << s; -} \ No newline at end of file +}