I don't see why that wouldn't work. The operator[] for strings returns a char just like it does for C-style strings.
I don't see why that wouldn't work. The operator[] for strings returns a char just like it does for C-style strings.
If you must use STL strings, but for some reason you want to access the Cstyle string the STL string is based on (STL string class has a char * as a private/protected data member to hold the C style string), you can use the c_str() method to get the underlying C style string. However, as jlou posted, the [] works for STL strings just as it does for Cstyle strings so there really isn't any need for pulling out the Cstyle string in this instance.