Erase string content - C++ STL

C++ examples for STL:string

Description

Erase string content

Demo Code

#include <iostream>
#include <string>
using namespace std;
int main()//from   w  w w .  j ava 2s  .c om
{
   string str1("Alpha");
   string str2("Beta");
   string str3("Gamma");
   string str4;
   str4 = str1 + str3;
   cout << "Erasing str4.\n";
   str4.erase();
   if(str4.empty()) cout << "str4 is now empty.\n";
   cout << "Size and capacity of str4 is " << str4.size() << " "
   << str4.capacity() << "\n\n";
   return 0;
}

Result


Related Tutorials