freinds
freinds

Reputation: 59

C Memory address problem

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

Answers (2)

Martin Drlík
Martin Drlík

Reputation: 1454

int intarray[] = {0,11,12,13,14,15,...,19};
int* ptrA = intarray;

int v = *(ptrA + 5); // v == 15

Upvotes: 0

Simon Richter
Simon Richter

Reputation: 29586

It points to the sixth element. Pointer addition carries an implicit multiplication by the size of the target type.

Upvotes: 4

Related Questions