Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How concatenate a string and a const char?
- string a = "hello ";
- const char *b = "world";
- const char *C;
- string a = "hello ";
- const char *b = "world";
- a += b;
- const char *C = a.c_str();
- string a = "hello ";
- const char *b = "world";
- const char *C = (a + b).c_str();
- #include <string>
- ///...
- std::string str="foo";
- std::string str2=str+" bar";
- str+="bar";
- #include <sstream>
- //...
- std::string str1="hello";
- std::stringstream ss;
- ss << str1 << "foo" << ' ' << "bar" << 1234;
- std::string str=ss.str();
- my_c_func(str1.c_str());
- char *cp=std::malloc(str1.size()+1);
- std::copy(str1.begin(), str2.end(), cp);
- cp[str1.size()]='