concatenate str cpp code example
Example 1: concat string in c++
#include <iostream>
#include <sstream>
int main() {
std::string value = "Hello, " + "world!";
std::cout << value << std::endl;
std::ostringstream ss;
ss << "This is an integer" << 104;
std::cout << ss.str() << std::endl;
}
Example 2: appending string in c++
#include<iostream>
#include <string>
int main() {
std::string namee = "Caleb";
namee += " Hello";
std::cout << namee << std::endl;
std::string namee2 = std::string("Caleb")+" Hello";
std::cout << namee2 << std::endl;
std::cin.get();
}