Answers for "how to convert vector to string in c++"

C++
0

vector to string c++

std::vector<char> input({ 'a', 'b', 'c' });
std::string s(input.begin(), input.end());
Posted by: Guest on May-05-2021
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

Code answers related to "how to convert vector to string in c++"

Browse Popular Code Answers by Language