[ad_1]
strtok_s
is defined in the Annex K of the C Standard. These so called secure functions are optional and available mostly on Microsoft systems but with semantics different from the standard ones.
These functions are thus non portable and should not be used.
Another possible explanation is you did not include <string.h>
. You should post a full program so every possible explanation can be found.
You can either use strtok()
, which has several shortcomings but not a problem in your code, or the POSIX alternative strtok_r
if available on your system.
Note however that passing an empty string as the delimiter string is meaningless. The second argument should be a string with possible delimiters, such as ' '
, '\t'
, '\n'
for whitespace or explicit delimiters such as ','
.
The Microsoft documentation specifies this prototype:
char* strtok_s(
char* str,
const char* delimiters,
char** context
);
Whereas the C Standard has this one:
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
char *strtok_s(char * restrict s1,
rsize_t * restrict s1max,
const char * restrict s2,
char ** restrict ptr);
Even the prototypes are different and incompatible. Don’t use this function.
[ad_2]