'how I delete char in string?

There is a problem using the erase function.

when I input aaabbbbcc, only aaa is output.

But I want to print aaacc.

What is the problem with this code?

int main() {

    int i = 3;
    string a, temp_a;
    cin >> a;
    a.erase(i, i + 3);
    printf("%s", a.c_str());
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source