Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- string ns;
- int main()
- {
- string words = "one two three four five six";
- string word = "zero";
- int found = -1;
- int lastSpace = 0;
- do
- {
- found = words.find(" ", found+1);
- if(found!=-1)
- {
- lastSpace = found;
- }
- }
- // while(found<=words.length()-15);
- while(found!=-1);
- //words = words.substr(0,found) + " "+ word +words.substr(found);
- words = words.substr(0,lastSpace) + " "+ word +words.substr(lastSpace);
- cout << words;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement