C++ string operator []
#include <iostream> #include <string> using namespace std; int main()//from w w w. j a v a2s .c o m { int i; string str; cout << "Type in any sequence of characters: "; getline(cin,str); // Cycle through all elements of the string for (i = 0; i < int(str.length()); i++) str[i] = toupper(str[i]); cout << "The characters just entered, in uppercase, are: " << str << endl; cin.ignore(); return 0; }