# **[](https://en.cppreference.com/w/cpp/header/string)** provides `std::string` (mutable) and `std::string_view` (read-only, C++17). `std::string` is a dynamic array of characters with O(1) amortized append, O(1) random access, and utilities like `find()`, `substr()`, `replace()`. Use `std::string` for owned text; use `std::string_view` for non-owning references (parameters, returns). ## Example This example demonstrates string length queries, indexing, searching, and replacement operations. ```cpp // compile: g++ -std=c++11 -o stringexample stringexample.cpp // run: ./stringexample // description: string operations #include #include int main() { std::string s = "hello world"; std::cout << "length: " << s.length() << "\n"; std::cout << "at index 6: " << s[6] << "\n"; size_t pos = s.find("world"); std::cout << "found at: " << pos << "\n"; s.replace(0, 5, "goodbye"); std::cout << "after replace: " << s << "\n"; return 0; } ```