fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <sstream>
  5. #include <iterator>
  6. #include <algorithm>
  7. using namespace std;
  8.  
  9.  
  10. int main ()
  11. {
  12. string input = "";
  13. cout << "Input: ";
  14. cin >> input;
  15. string a,b;
  16. vector<string> objects;
  17.  
  18. for(stringstream sst(input); getline(sst, a, ','); )
  19. objects.push_back(a);
  20.  
  21.  
  22. copy (objects.begin(), objects.end(), ostream_iterator<string>(cout," - "));
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3420KB
stdin
aaa,bbb,ccc,ddd,eee
stdout
Input: aaa - bbb - ccc - ddd - eee -