0
#include<stdio.h> int main() { printf("%d", sizeof(void *)); return 0; }
what will be the output of this?
1 Answer
+ 1
Size of all pointers depends on machine word size. For example, if you have 32-bit processor sizeof any pointer will be 4 bytes, if 64-bit - 8 bytes.
and for the future I would like to note that the operation sizeof returns a value of type size_t, which, as a rule, is the largest unsigned integer type. For this it is worth using as a specifier of output format %zu.
e. g.: printf("%zd", sizeof(void*));
but on some unix-like systems %zd intended for ssize_t type, therefore you should use %zu.
or %llu
e. g.: printf("%llu", sizeof(void*));