subtracting two addresses giving wrong output
问题 int main() { int x = 4; int *p = &x; int *k = p++; int r = p - k; printf("%d %d %d", p,k,p-k); getch(); } Output: 2752116 2752112 1 Why not 4 ? And also I can't use p+k or any other operator except - (subtraction). 回答1: First of all, you MUST use correct argument type for the supplied format specifier, supplying mismatched type of arguments causes undefined behavior. You must use %p format specifier and cast the argument to void * to print address (pointers) To print the result of a pointer