小编nta*_*lli的帖子

在64位机器上strtok

以下代码在64位和32位上的工作方式不同,这使我无法移植代码.

char * tmp = "How are you?";
printf("size of char * = %ld and size of strtok return val = %ld \n",sizeof(char *),sizeof(strtok(tmp," ")));
Run Code Online (Sandbox Code Playgroud)

以下是输出:

32 bit: 
size of char * = 4 and size of strtok return val = 4 

64 bit:

size of char * = 8 and size of strtok return val = 4
Run Code Online (Sandbox Code Playgroud)

strtok的手册页说:

   #include <string.h>

   char *strtok(char *str, const char *delim);

RETURN VALUE
       The strtok() and strtok_r() functions return a pointer to the next …
Run Code Online (Sandbox Code Playgroud)

c strtok 32bit-64bit

8
推荐指数
1
解决办法
1062
查看次数

标签 统计

32bit-64bit ×1

c ×1

strtok ×1