#include <stdio.h>
int main()
{
printf("%u\n", sizeof(char *));
}
32- , 4. 64- 8. ( 64- , .)
, char *str = malloc(sizeof(char *) * 5); 20 40 , str. , c-type str, 19 39.
I am on 64-bit Ubuntu 14.04. In a 64-bit environment, you can test the above code example with the following compiler options.
$ gcc -m32 -o out32 main.c
$ ./out32
4
$ gcc -o out64 main.c
$ ./out64
8
If you receive an error message sys/cdefs.h: No such file or directory, install the following packages.
$ sudo apt install libx32gcc-4.8-dev
$ sudo apt install libc6-dev-i386
(The resulting package names from this article )
nglee source
share