El siguiente código funciona de manera diferente en 64 bits y en 32 bits, lo que me está causando problemas para portar mi código.strtok en máquinas de 64 bits
char * tmp = "How are you?";
printf("size of char * = %ld and size of strtok return val = %ld \n",sizeof(char *),sizeof(strtok(tmp," ")));
A continuación se presenta la salida:
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
La página del manual de strtok dice:
#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.
Se supone que el char * en una máquina de 64 bits a ser de 8 bytes como impresa. Entonces, ¿por qué Strtok devuelve un puntero de 4 bytes en una máquina de 64 bits?
Gracias
¿Qué compilador está utilizando para obtener estos resultados? – Joel
¿Has olvidado incluir ''? Entonces el compilador podría estar en el estado de ánimo tradicional y asumir el tipo de retorno 'int' para las funciones que no conoce. –
Confirmado en 'gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2'. Loca. – sarnold