fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. void splitString(const string &str, char delimiter, vector<string> * out) {
  7. string::size_type start = 0, pos = str.find(delimiter);
  8. while (pos != string::npos) {
  9. out->push_back(str.substr(start, pos-start));
  10. start = pos + 1;
  11. pos = str.find(delimiter, start);
  12. }
  13. if (start < str.size())
  14. out->push_back(str.substr(start));
  15. }
  16.  
  17. int main() {
  18. vector<string> user_input_tokens;
  19. string port = "209,202,252,54,19,15";
  20. splitString(port, ',', &user_input_tokens);
  21. for (string str : user_input_tokens) {
  22. cout << str << ".";
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
209.202.252.54.19.15.