fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. void exec(char* args[])
  8. {
  9. for (int i = 0; args[i] != NULL; ++i)
  10. cout << args[i] << endl;
  11. }
  12.  
  13. int main()
  14. {
  15. string temp = "some text and stuff here";
  16. stringstream s (temp);
  17.  
  18. vector<string> tokens;
  19. while(s>> temp)
  20. {
  21. tokens.push_back(temp);
  22. }
  23.  
  24. int counter = 0;
  25. char *args[100];
  26. for (auto it = tokens.begin(); it != tokens.end(); ++it)
  27. args[counter++] = const_cast<char*>(it->c_str());
  28. args[counter] = NULL;
  29.  
  30. exec(args);
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
some
text
and
stuff
here