Advertisement
Shuva_Dev

Tokenize in C++

Nov 17th, 2022
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     string str = "1 2 3 4 5";
  6.     string token;
  7.  
  8.     stringstream s;
  9.     s << str;
  10.     // s >> token;
  11.     while(getline(s, token, ' ')) {
  12.         cout << token << endl;
  13.     }
  14.  
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement