I need to cast only 1
string. The opposite way is pretty simple like
The following did not work for me:
char c = 34; string(1,c); //this doesn't work, the string is always empty. string s(c); //also doesn't work. boost::lexical_cast<string>((int)c); //also doesn't work.
std::string s(1, c); std::cout << s << std::endl;
std::cout << std::string(1, c) << std::endl;
std::string s; s.push_back(c); std::cout << s << std::endl;
worked for me.