fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. std::string str = "123456789";
  7. cout << sizeof(std::string) << " " << str.capacity() << endl;
  8. str.erase(4);
  9. cout << str << " " << str.size() << ' ' << str.capacity();
  10.  
  11.  
  12. return 0;
  13. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
4 9
1234 4 9