fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. //---cell separation---
  5. using namespace std;
  6. //---cell separation---
  7. vector<string> split(string input, char delim){
  8. vector<string> ret;
  9. string temp;
  10. for(char letter:input){
  11. if(letter!=delim){
  12. temp+= letter;
  13. }else{
  14. ret.push_back(temp);
  15. temp.clear();
  16. }
  17. }
  18. ret.push_back(temp);
  19. return ret;
  20. }
  21. int main(){
  22. string test = "This is a test.";
  23. vector<string> result = split(test, ' ');
  24. for(auto s: result){
  25. cout << s << endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
This
is
a
test.