#include<stdio.h> int main() { printf("%d", sizeof(void *)); return 0; } | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

#include<stdio.h> int main() { printf("%d", sizeof(void *)); return 0; }

what will be the output of this?

17th Aug 2018, 7:41 AM
Shah Kevin
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*));
17th Aug 2018, 8:04 AM
Roman Khristoforov
Roman Khristoforov - avatar