Advertisement
saira12tabassum19

mimics strtok

Aug 13th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. string string_strtok(string str)
  4. {
  5.     vector <string> tokens;
  6.     stringstream s(str);
  7.     string str2;
  8.    while(getline(s, str2, ' '))
  9.     {
  10.         tokens.push_back(str2);
  11.     }
  12.  
  13. for(int i = 0; i < tokens.size(); i++)
  14.         cout << tokens[i] <<endl;
  15. }
  16. int main()
  17. {
  18.  
  19.     string str;
  20.     getline(cin,str);
  21.   string_strtok(str);
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement