Preferred conversion from char (not char*) to std::string

后端 未结 5 1947
花落未央
花落未央 2021-01-01 08:55

I have a char, a plain old character, that I would like to turn into an std::string. std::string(char) doesn\'t exist of course. I c

5条回答
  •  轮回少年
    2021-01-01 09:11

    To add to the answer, you can simply use initializer list

    std::string str = {ch};
    

提交回复
热议问题