I am using Visual Studio 2015, and I am trying to use strtok_r. For some reason the compiler is not recognizing it.
Here is my code:
#include <string.h>
#include <stdlib.h>
#include <assert.h>
char** str_split(char* a_str, const char a_delim, int * argc)
{
... some other code
if (result)
{
size_t idx = 0;
char* saveptr = a_str;
char* token = strtok_r(a_str, delim, &saveptr);
//char * token;
while (token)
{
assert(idx < count);
*(result + idx++) = strdup(token);
token = strtok_r(0, delim, &saveptr);
}
assert(idx == count - 1);
*(result + idx) = 0;
}
return result;
I have been following this documentation: http://linux.die.net/man/3/strtok_r
Is the function deprecated? or am I making a silly mistake? Thank you in advance guys.
strtok_r()
on POSIX-ish systems is equivalent tostrtok_s()
on Windows systems. That equivalence does not always work, but in this specific case, it does.