Answers for "vector of int to string c++"

C++
0

vector of int to string c++

#include <vector> // vector 
#include <sstream> // string stream 
#include <iterator> // ostream_iterator 
#include <iostream> // cout 
using namespace std;

int main()
{
    vector<int> nums = {10, 7, 76, 415};
    stringstream result;
    copy(nums.begin(), nums.end(), std::ostream_iterator<int>(result, ""));
    string n = result.str();
    cout << n;
}
Posted by: Guest on July-26-2021

Browse Popular Code Answers by Language