Finding the size of a pointer
printf("pointer: %d\n", sizeof(*void));
This line results in a 开发者_如何学Csyntax error because of the *. What should I do to get it to work?
You are currently trying to find out the size that is at address void. If you are looking to find the size of a void pointer perhaps try: sizeof(void*) instead.
printf("pointer: %zu\n", sizeof(void*));
should do what you want. Use %zu and not %d as the pointer is an unsigned value and not a decimal.
Edit: Something else that I just thought of for the first time, is %zu compiler dependent? Do we need to do things differently on 32bit or 64bit architecture?
printf("pointer: %d\n", sizeof(void*));
精彩评论