下列程序的输出结果是
#include<iostream> using namespace std; int main() { int a[] = {2, 4, 6, 8, 10}, *p, **k; p = a; k = &p; printf(" % d", *(p++)); printf(" % d\n", **k); return 0; }
Remember that both postfix and unary forms of ++ and -- have a result and a side effect:
The result of x++ is the current value of x - as a side effect, x is incremented by 1 (if x is a pointer, it is incremented to point to the next object in a sequence);
The result of ++x is the current value of x plus 1 - as a side effect, x is incremented by 1 (if x is a pointer, the result is the address of the next object in a sequence, and x is updated to point to the next object in a sequence);