Last active
February 16, 2017 14:09
-
-
Save tautologico/2ed7901821d41a43f0835ba32e92add9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sstream> | |
#include <vector> | |
#include <iterator> | |
#include <iostream> | |
using namespace std; | |
template <typename T> | |
vector<T> read_vector(const string& s) { | |
istringstream iss(s); | |
vector<T> result { istream_iterator<T>(iss), istream_iterator<T>() }; | |
return std::move(result); | |
} | |
int main() { | |
string s = "Aftas arden Ausmachen dass den die Toten Hosen"; | |
string sn = "145 67 32 99"; | |
cout << "Strings: " << endl; | |
vector<string> tokens = read_vector<string>(s); | |
for (auto& t : tokens) { | |
cout << t << endl; | |
} | |
cout << endl; | |
cout << "Numeros: " << endl; | |
vector<int> nums = read_vector<int>(sn); | |
for (auto& n : nums) { | |
cout << n << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment