Reputation: 59
int intarray[256] = {0, 11, 12, 13, 14, 15, 16, 17, 18, 19};
int* ptrA;
ptrA = &intarray[0];
if pta is the content of the local variable, which is the address of intarray[0], then what is the pta +5 means?
anyone can explain? thanks
Upvotes: 0
Views: 289
Reputation: 1454
int intarray[] = {0,11,12,13,14,15,...,19};
int* ptrA = intarray;
int v = *(ptrA + 5); // v == 15
Upvotes: 0
Reputation: 29586
It points to the sixth element. Pointer addition carries an implicit multiplication by the size of the target type.
Upvotes: 4