Can anyone explain why I am getting segmentation fault in the following example?
#include
#include
int main(void) {
char
You have understood the usage of strtok_r incorrectly. Please check this example and documentation
And try & see this:
#include
#include
int main(void)
{
char hello[] = "Hello World, let me live.";
char *tmp;
char *token = NULL;
for(token = strtok_r(hello, ", ", &tmp);
token != NULL;
token = strtok_r(NULL, ", ", &tmp))
{
printf("%s\n", token);
}
return 0;
}