C++ examples for STL:string
Display the characters in a string one at a time by using the indexing operator.
#include <iostream> #include <string> using namespace std; int main()//from ww w . j av a2s .c o m { string str1("Alpha"); string str2("Beta"); string str3("Gamma"); string str4; for(unsigned i = 0; i < str1.size(); ++i) cout << "str1[i]: " << str1[i] << endl; cout << endl; return 0; }