Is %p specifier only for valid pointers?
问题 Suppose on my platform sizeof(int)==sizeof(void*) and I have this code: printf( "%p", rand() ); Will this be undefined behavior because of passing a value that is not a valid pointer in place of %p ? 回答1: To expand upon @larsman's answer (which says that since you violated a constraint, the behavior is undefined), here's an actual C implementation where sizeof(int) == sizeof(void*) , yet the code is not equivalent to printf( "%p", (void*)rand() ); The Motorola 68000 processor has 16 registers