/** Pointer arithmetic. */ #include using namespace std; int main() { int v[] = {2, 4, 6, 8, 12}; int *vPtr = v; cout << *vPtr << endl; // prints 2 vPtr = vPtr + 3; // vPtr now points to address vPtr + 3*sizeof(int), // i.e., v[3] cout << *vPtr << endl; // prints v[3] vPtr--; // vPtr now points to address vPtr - 1*sizeof(int), // i.e., v[2] cout << *vPtr << endl; // prints v[2] cout << *(vPtr + 2) << endl; // prints v[4] return 0; }