fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char sorce[] = "a\nAB\nabc\nABCD\nabcde\nABCDEF\n";
  9. vector <char*>ans;
  10.  
  11.  
  12. char *pch = strtok (sorce,"\n");
  13. for (;pch != NULL;)
  14. {
  15. ans.push_back(pch);
  16. pch = strtok (NULL, " ,.-");
  17. }
  18.  
  19. for(int i = 0; i < ans.size(); i++)
  20. cout << ans[i] << endl;
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
a
AB
abc
ABCD
abcde
ABCDEF