Advertisement
saira12tabassum19

mimics strtok

Aug 13th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 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.  
  7.  
  8.     stringstream s(str);
  9.  
  10.     string str2;
  11.    while(getline(s, str2, ' '))
  12.     {
  13.         tokens.push_back(str2);
  14.     }
  15.  
  16. for(int i = 0; i < tokens.size(); i++)
  17.         cout << tokens[i] <<endl;
  18. }
  19. int main()
  20. {
  21.  
  22.     string str;
  23.     getline(cin,str);
  24.   string_strtok(str);
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement