다음 코드는 64 비트와 32 비트에서 다르게 작동하므로 내 코드를 포팅하는 데 문제가 있습니다.64 비트 컴퓨터의 strtok
이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
strtok를의 남자 페이지가 말한다 : 64 비트 컴퓨터에 숯불 * 인쇄로 8 바이트 있어야하는데
#include <string.h>
char *strtok(char *str, const char *delim);
RETURN VALUE
The strtok() and strtok_r() functions return a pointer to the next token, or NULL if there are no more tokens.
char * tmp = "How are you?";
printf("size of char * = %ld and size of strtok return val = %ld \n",sizeof(char *),sizeof(strtok(tmp," ")));
다음은 출력됩니다. 그렇다면 왜 strtok은 64 비트 머신에서 4 바이트 char 포인터를 반환합니까 ??
감사
이러한 결과를 얻으려면 어떤 컴파일러를 사용하고 있습니까? – Joel
''을 잊어 버렸습니까? 그렇다면 컴파일러는 전통적인 기분에있을 수 있으며, 알 수없는 함수에 대해서는 int 형을 반환합니다. –
'gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2'에서 확인되었습니다. 미친. – sarnold