以下代码在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)