pointer value

M

Michael Mair

JD said:
int (*a)[10];
a++;
what will be the value of a?

As always with ++ on a pointer:
(unsigned char *)a + 1*sizeof *a

As a points to array 10 of int, sizeof *a == 10 * sizeof (int).

As you have not initialised the pointer, the behaviour is
undefined.

Cheers
Michael
 
C

CBFalconer

JD said:
int (*a)[10];
a++;
what will be the value of a?

You answer this by considering what a is. It is a pointer to an
array of 10 ints. Since it is uninitialized, incrementing it (or
dereferencing it) results in undefined behavior.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,167
Messages
2,570,911
Members
47,453
Latest member
MadelinePh

Latest Threads

Top