//c++中按照格式输入输出 类似于c 语言中的 sprintf函数
#include<iostream>
#include<sstream>//std::stringstream 头文件
int main() {
std::string str = "高海文";
std::stringstream sstr;//把任意基本类型转换为string
sstr << 123 << '_' << 3.14 << '_' << "_ABC_" << str;
sstr >> str;
std::cout << str << std::endl;
return 0;
}
c++可以把任意基本类型转换为string, 类似于c 语言中的 sprintf函数
猜你喜欢
转载自blog.csdn.net/weixin_42204566/article/details/84710061
今日推荐
周排行