私はVisual Studio 2015を使用していますが、strtok_rを使用しようとしています。何らかの理由でコンパイラが認識できません。ここでStrtok_r未解決の外部シンボル
は私のコードです:
#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;
私はこの文書を、次のされています:http://linux.die.net/man/3/strtok_r
は非推奨機能ですか?または私は愚かな間違いをしていますか?先輩にありがとう。
MSが完全にPOSIXに準拠していません。 MSツールを使用してプログラミングする場合は、Linuxのマニュアルではなく、[MS documentation](https://msdn.microsoft.com/en-us/library/2c8d19sb.aspx)を読む必要があります。 – kaylum
実際には、POSIX-ishシステムの 'strtok_r()'はWindowsシステムの 'strtok_s()'に相当します。その同値性は必ずしも働くわけではありませんが、この特定のケースではそうです。 –