/* Author: Arun Somasundaram, CSE Dept, OSU Simple program for string usage */ #include #include using namespace std; int main(){ string str1; str1 = "How Are You?"; cout << str1 << endl; string str2(str1); cout << str2 << endl; string str3(str1, 4, 3); cout << str3 << endl; string str4; cout << "Enter string : "; getline(cin, str4); cout << str4 << endl; string str5; cout << "Enter string : "; cin >> str5; cout << str5 << endl; string str6 = "Hello"; str6 += " There"; cout << str6 << endl; for(int i = 0; i < str6.length(); i++){ cout << str6.at(i) << endl; } for( string::iterator iIterator = str6.begin(); iIterator != str6.end(); iIterator++ ){ cout << *iIterator << " "; } cout << endl; if (!str6.empty()) cout << "Not empty" << endl; string str7 = "Hello"; string str8 = "Hello"; int equal78 = str7.compare(str8); cout << equal78 << endl; //0 if equal cout << str6.find("There") << endl; return 0; }