How do I convert a single char to a string?

后端 未结 11 1797
醉梦人生
醉梦人生 2020-12-18 17:24

I\'d like to enumerate a string and instead of it returning chars I\'d like to have the iterative variable be of type string. This pro

11条回答
  •  天涯浪人
    2020-12-18 18:12

    you can use + with empty string "", please check the below code:

    char a = 'A';
    //a_str is a string, the value of which is "A".
    string a_str = ""+a;
    

提交回复
热议问题