fork download
  1. #include <sstream>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<string> strings;
  9. istringstream texto("test;car;bar;mouse");
  10. string token;
  11. while (getline(texto, token, ';')) {
  12. cout << token << endl;
  13. strings.push_back(token);
  14. }
  15. cout << "value by position 0 " << strings[0];
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/446887/101
Success #stdin #stdout 0s 4208KB
stdin
Standard input is empty
stdout
test
car
bar
mouse
value by position 0 test