C++ examples for STL:string
Erase string content
#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; }