stringstream——整型和字符串的相互转化

void x_str(int x, string &str) {    // int 转 string 
    stringstream ss;
    ss << x;          //ss一定在左边
    ss >> s;
}
void str_x(string str, int &x) {    // string 转 int 
    stringstream ss;
    ss << s;
    ss >> x;
}
全部评论

相关推荐

07-17 11:27
门头沟学院 Java
点赞 评论 收藏
分享
07-19 13:28
长沙学院 Java
程序员小白条:你有面试就有希望,没面试自然就没希望,到时候就知道了,你问别人也没啥用处的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务