#include#include using namespace std; int main() { string str1 = "hello"; string str2 = "world"; string str3 = str1 + " " + str2; cout << str3 << endl; return 0; }
#includeThis example shows how to search for a substring within a string using the find function. Package library: Standard Template Library (STL)#include using namespace std; int main() { string str("The quick brown fox jumps over the lazy dog"); size_t pos = str.find("fox"); if (pos != string::npos) { cout << "Found at position " << pos << endl; } else { cout << "Not found" << endl; } return 0; }