I am confused with this block of code:
ipPtr = ipPtr + 3; // 5 cout << *ipPtr << endl; Why the cout is not 5 but some random large number? can anyone explain to me please. As my understanding I thought the cout << *ipPtr << endl; is pointed to the *ipPtr above it. Am I right ?
#include <iostream> void main(){ using namespace std; int iaArray[] = {1,2,3,4,5}; int* ipPtr = 0; ipPtr = &(iaArray[1]); cout << *ipPtr << endl;//2 ++ipPtr; cout << *ipPtr << endl;//3 ipPtr = ipPtr + 3; //not 5 but random number. cout << *ipPtr << endl; }