#Arrays and pointers

13 messages · Page 1 of 1 (latest)

hallow jungle
#

From my understanding an array points to index 0 but when I print out the pointers of the a[0] and a they are not the same. Could someone more experienced explain this?

floral dustBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

thorny cliff
#

a[i] is an int. not pointer.

#

a "decays to" a pointer

#

you should see the difference between you %p output being sizeof(int)

hallow jungle
#

should the memory adress of a[0] and a be the same?

thorny cliff
#

yes

#

assert( a == &a[0] );

hallow jungle
#

how does it decay to a pointer

thorny cliff
#

just means a syntax is teh same as saying &a[0]

hallow jungle
#

ok thank you

floral dustBOT
#

@hallow jungle Has your question been resolved? If so, run !solved :)

hallow jungle
#

!solved