It's easy if both strings are std::string objects.
std::string MyString = string1 + string2;
or if you wish to append second into first one:
string1.append(string2);
but my problem is add inside\middle of string1
Sample code for insert:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
#include <string>
int main()
{
std::string string1 = "hello world";
std::string string2 = "hello2";
const size_t pos = string1.find("world");
string1.insert(pos, string2 + " ");
std::cout << string1 << std::endl;
std::cin.get();
return 0;
}
|
Last edited on
thank you so much for all... it's working like i need