tags:

views:

117

answers:

2
printf("pointer: %d\n", sizeof(*void));

This line results in a syntax error because of the *. What should I do to get it to work?

+5  A: 
printf("pointer: %d\n", sizeof(void*));
Marcelo Cantos
+8  A: 

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?

shuttle87