#include#include int main() { std::string myString = "Hello, world!"; std::cout << myString << std::endl; // Output: "Hello, world!" return 0; }
#include#include int main() { std::string str1 = "Hello, "; std::string str2 = "world!"; std::string result = str1 + str2; std::cout << result << std::endl; // Output: "Hello, world!" return 0; }
#includeThe package library for "cpp std string" is the C++ Standard Library, which is included with most C++ compilers.#include int main() { std::string myString = "The quick brown fox jumps over the lazy dog"; std::size_t found = myString.find("fox"); if (found != std::string::npos) { std::cout << "Substring found at position " << found << std::endl; } else { std::cout << "Substring not found" << std::endl; } return 0; }