SHARE
TWEET

Untitled

a guest Jan 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string line = "hello, world, bye";    
  2. char * pch = strtok(line.c_str(),",");
  3.    
  4. error: invalid conversion from ‘const char*’ to ‘char*’
  5. error: initializing argument 1 of ‘char* strtok(char*, const char*)’
  6.    
  7. std::string::size_type pos = line.find_first_of(',');
  8. std::string token = pos.substr(0, pos);
  9.    
  10. istringstream is(line);
  11. string part;
  12. while (getline(is, part, ','))
  13.   cout << part << endl;
  14.    
  15. std::vector<char> buffer(line.c_str(), line.c_str()+line.size()+1);
  16. char * pch = strtok(&buffer[0], ",");
  17.    
  18. std::stringstream ss(line);
  19. std::string token;
  20. std::readline(ss, token, ',');
  21.    
  22. std::string token(line, 0, line.find(','));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top