首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >C++向量转字符串?

C++向量转字符串?
EN

Stack Overflow用户
提问于 2018-02-07 08:05:16
回答 2查看 0关注 0票数 0

我有一个vector<int>具有整数

"1,2,3,4"

这样做:

>>> array = [1,2,3,4]
>>> ",".join(map(str,array))
'1,2,3,4'
EN

Stack Overflow用户

发布于 2018-02-07 17:25:24

使用std::Copy和std::ostream_迭代器

#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>


int main()
{
    int  array[] = {1,2,3,4};

    std::copy(array, array+4, std::ostream_iterator<int>(std::cout,","));
}
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100003473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档