M
Mark
Hello,
consider this piece:
int x;
printf("address of x %p\n", &x); /* 1*/
printf("address of x %p\n", (void *)&x); /* 2 */
Are these expressions equivalent?
gcc-4.1 on my system sensibly complains on the first 'printf', but both
outputs are the same. I do understand that if printf()'s %p specifier
requires its argument to be a pointer to void, then the behavior of the (1)
is undefined ? On the other hand, a pointer can be converted to (void *).
PS. I tend to use the second form.
consider this piece:
int x;
printf("address of x %p\n", &x); /* 1*/
printf("address of x %p\n", (void *)&x); /* 2 */
Are these expressions equivalent?
gcc-4.1 on my system sensibly complains on the first 'printf', but both
outputs are the same. I do understand that if printf()'s %p specifier
requires its argument to be a pointer to void, then the behavior of the (1)
is undefined ? On the other hand, a pointer can be converted to (void *).
PS. I tend to use the second form.