Raheel Bari
0
Q:

string to vector c++

#include <iostream>
#include <string>
#include <vector>
 
int main()
{
    std::string s = "Hello World!";
 
    std::vector<char> v(s.begin(), s.end());
 
    for (const char &c: v)
        std::cout << c;
 
    return 0;
}
1
#include <sstream>
#include <vector>
#include <string>

std::string myString = "10 15 20 23";
std::stringstream iss( myString );

int number;
std::vector<int> myNumbers;
while ( iss >> number )
  myNumbers.push_back( number );
0

New to Communities?

Join the community