ptr =strtok(answer.c_str()," \t\n,()");
Error message:
invalid conversion from `const char*' to `char*'
Please quote what you are replying to.
In this case, my guess is that you are showing us some code. Thank you... As
I said in my previous post, look more closely and realize that what c_str()
returns is not compatible with what strtok takes.
In other words, please check the documentations for c_str and strtok. You
may realize that strtok takes a 'char*' and unfortunately, c_str DOES NOT
return that type.
You need to copy the characters that are returned by c_str into a buffer,
then call strtok with that buffer:
#include <string.h>
/* ... */
// WARNING: buffer may be leaked if an exception is thrown
// before getting to the free(buffer) call below
//
// Also, strdup is not standard but exists on many systems
char * buffer = strdup(answer.c_str());
ptr = strtok(buffer, /* ... */);
/* ... */
free(buffer);
Ali