#include #include using namespace std; int main() { string hw; hw.reserve(100); cout << "My string lenght is :" << hw.size() << endl; cout << "My string is empty? " << hw.empty() << endl; cout << "My string capacity is :" << hw.capacity() << endl; hw ="Hello world"; cout << hw << endl; cout << "My string lenght is :" << hw.size() << endl; cout << "My string is empty? " << hw.empty() << endl; cout << "My string capacity is :" << hw.capacity() << endl; hw+="!"; cout << hw << endl; // string e' un container! for (string::const_iterator c=hw.begin(); c!=hw.end(); ++c) { cout << *c << endl; } cout << "My string lenght is :" << hw.size() << endl; cout << "My string capacity is :" << hw.capacity() << endl; cout << "String [4] " << hw[4] << endl; hw.append("Oggi e' martedi'"); cout << hw << endl; hw.append(hw.begin()+5, hw.begin()+10); cout << hw << endl; hw.push_back(*(hw.begin()+8)); cout << hw << endl; hw.erase(12, 15); // cancella da 12, 15 caratteri cout << hw << endl; hw.erase(12); // cancella da 12 alla fine cout << hw << endl; hw.replace(0,5,"ciao"); // sostituisce 4 caratteri a partire da 6 con "ciao" cout << hw << endl; string hate("fuck you, world!"); cout << hate << endl; hw.swap(hate); cout << "hw " << hw << endl; cout << "hate " << hate << endl; cout << "Find '!' " << hw.find("!") << endl; cout << "Find '!' " << hw[hw.find("!")] << endl; cout << "hw vs hate " << (hw> hw; cout << hw; return 0; }