Advertisement
obernardovieira

New Split String

Mar 5th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <sstream>
  5.  
  6.  
  7. int main() {
  8.     std::string comando("oi mundo lindo");
  9.     std::vector<std::string> cmd;
  10.     std::string cmds;
  11.     std::istringstream buf(comando);
  12.    
  13.     while (std::getline(buf,cmds, buf.widen(' '))) {
  14.         cmd.push_back(cmds);
  15.     }
  16.    
  17.     std::cout << cmd[0] << std::endl;
  18.     std::cout << cmd[1] << std::endl;
  19.     std::cout << cmd[2] << std::endl;
  20.    
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement