I'm not going to mention the bugs mentioned in the comments.
I would avoid trying to manipulate the same string being searched.
Particularly with a range-based for loop which will use iterators. Iterators may be invalidated by altering the underlying collection, often coinciding with dynamic memory (re)allocation. I don't know how string iterators work off the top of my head, but I would guess that as you grow the string you're invalidating your iterators.
I would create a second string, scan the first string to determine how many vowels there are, and reserve that much space immediately. This requires iterating over the first string twice, but you should only invoke heap allocation at most once.
Then simply iterate over the first string and populate the second.
#include <iostream>
#include <string>
#include <algorithm>
bool is_vowel(char c)
{
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
int main()
{
const std::string vowel_postfix = "ob";
std::string in, out;
std::cin >> in;
auto vowel_count = std::count_if(in.begin(), in.end(), is_vowel);
out.reserve(in.length() + vowel_count * 2);
for (char c : in) {
out.push_back(c);
if (is_vowel(c))
out.insert(out.length(), vowel_postfix);
}
std::cout << out << std::endl;
}