Monday, 15 February 2010

c++ - converting a std::string to an array of c strings -



c++ - converting a std::string to an array of c strings -

this question has reply here:

how tokenize string in c++? 32 answers

i'm trying find way convert string array of c strings. illustration string be:

std::string s = "this string."

and output this:

array[0] = array[1] = array[2] = array[3] = string. array[4] = null

split string multiple strings based on delimiter using boost library function 'split' this:

#include <boost/algorithm/string.hpp> std::vector<std::string> strs; boost::split(strs, "string split", boost::is_any_of(" "));

and iterate on strs vector.

this approach allows specify many delimiters like.

see here more: http://www.boost.org/doc/libs/1_48_0/doc/html/string_algo/usage.html#id3115768

and there plethora of approaches here: splitting string in c++

c++

No comments:

Post a Comment