Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string line = "hello, world, bye";
- char * pch = strtok(line.c_str(),",");
- error: invalid conversion from ‘const char*’ to ‘char*’
- error: initializing argument 1 of ‘char* strtok(char*, const char*)’
- std::string::size_type pos = line.find_first_of(',');
- std::string token = pos.substr(0, pos);
- istringstream is(line);
- string part;
- while (getline(is, part, ','))
- cout << part << endl;
- std::vector<char> buffer(line.c_str(), line.c_str()+line.size()+1);
- char * pch = strtok(&buffer[0], ",");
- std::stringstream ss(line);
- std::string token;
- std::readline(ss, token, ',');
- std::string token(line, 0, line.find(','));
Add Comment
Please, Sign In to add comment