std::string str1 = "Hello"; std::string str2 = "World!"; std::string concatStr = str1 + " " + str2;
std::string str1 = "Hello"; std::string str2 = "Hello"; if(str1 == str2) std::cout << "Strings are equal"; else std::cout << "Strings are not equal";
std::string str = "Hello World!"; std::string substr = str.substr(6, 5);In this example, we are extracting a part of the string "Hello World!" starting from index 6 and with a length of 5 characters. Package library: