Chadrick Blog

reading a line from cin and splitting it

#include "pch.h"
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int main()
{
	
	string something;

	getline(cin, something);

	cout << "saved string: " << something;

	istringstream iss(something);
	
	vector<string> results(istream\_iterator<string>{iss}, istream\_iterator<string>());

	cout << "results size: " << results.size() << '\\n';

	for (int i = 0; i < results.size(); i++) {
		cout << results.at(i);
	}

	return 0;
}