// STL9.cp #include #include int main() { std::string a = "Standard strings are easy to initialize."; a += " And they can grow without end as needed."; std::string::iterator iter = std::find(a.begin(), a.end(), 'A'); if (iter != a.end()) { std::size_t offset = iter - a.begin(); a[offset] = 'a'; // They use array notation like C strings. } iter = std::find(a.begin(), a.end(), '.'); if (iter != a.end()) { a.erase(iter); // They are STL containers. } std::cout << a << std::endl; std::cout << "Size is "; // std::cout << strlen(a); // No coercion to char *. std::cout << std::strlen(a.c_str()); // But it easy to get a char *. // std::cout << a.size(); // Better... std::cout << "." << std::endl; // They automagically delete their allocated memory when they go out of scope. } // Standard strings are easy to initialize and they can grow without end as needed. // Size is 80.