[ create a new paste ] login | about

Link: http://codepad.org/E5p2UR2r    [ raw code | output | fork ]

C++, pasted on Mar 24:
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
using namespace std;

vector<int> parseLine(string line);

int main()
{
vector<int> coll = parseLine("3 22   4 5 88 9");
for(int i(0); i < static_cast<int>(coll.size()); ++i)
cout << coll[i] << endl;
}
vector<int> parseLine(string line)
{
  vector<int> coll;	// coll for collection, its just my naming :)
  istringstream source(line);
  for(int x; source >> x; )
    coll.push_back(x);

  return coll;
}


Output:
1
2
3
4
5
6
3
22
4
5
88
9


Create a new paste based on this one


Comments: