char转成string A Look at the Impact of '${char}'.

示例示例将char转换为string可以使用C++标准库中的string类的构造函数,如下所示:输出:

示例示例将char转换为string可以使用C++标准库中的string类的构造函数,如下所示:输出:

将char转换为string可以使用C++标准库中的string类的构造函数,如下所示:


cpp
#include 
#include 
int main()
{
    char c = 'a';
    std::string s(1, c);  // 构造函数:string(size_type count, char ch)
    std::cout << s << std::endl;
    return 0;
}

输出:

a

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(290)
qr code全称:利用QR Code实现快速信息传输
上一篇
html 代码编辑器:Welcome to My Website!
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(82条)