Navigation



17.4 — std::string character access and conversion to C-style arrays

Character access

There are two almost identical ways to access characters in a string. The easier to use and faster version is the overloaded operator[]:

char& string::operator[] (size_type nIndex) const char& string::operator[] (size_type nIndex) const

Both of these functions return the character with index nIndex Passing an invalid index results in undefined behavior Using . . . → Read More: 17.4 — std::string character access and conversion to C-style arrays