Added code to get a non-const char* from a std::string
This commit is contained in:
@@ -11,8 +11,10 @@ namespace connect_code {
|
||||
/* Tokenizes a string, based on the given delimiter */
|
||||
std::vector<std::string> tokenize_str(std::string str, std::string delim) {
|
||||
std::vector<std::string> result;
|
||||
char* c_str = str.data();
|
||||
char* c_delim = delim.data();
|
||||
/* &str[0] is used to convert an std::string to a char*. I tried using string.data(),
|
||||
but that appears to return a const char*. */
|
||||
char* c_str = &str[0];
|
||||
char* c_delim = &delim[0];
|
||||
|
||||
char* tok = strtok(c_str, c_delim);
|
||||
while (tok != NULL) {
|
||||
|
Reference in New Issue
Block a user