Hi, crap title I know, but couldn't think of anything else.
Em, an array in its simplest is a collection of variables in a contiguous block..right?
So if I have
Code:
int myarray[10] = {1,2,3,4,5,6,7,8,9} ;
that declares the container...but I want to understand its pointer counterpart
myarray is a pointer to int* , when used on its own it decays..so I can do which is similar to is a bit confusing however.
myarray doesn't decay to a pointer so it returns an address to a collection of 10 integers so its type is I think..an address to the whole array.
but this is what I am trying to understand the most
&myarray[0] ;
This is why it was confusing me:
if I had this array
Code:
char *person-name[]={"John","Doe","Purcell"}
declares an array containing 3 pointers.
person-name on its own decays to a pointer to the first element, which in turn holds a pointer to the string "John"
&person-name returns a pointer to the whole array I think?
but this or doesn't make sense to me.
dereferences myarray to give me 1 so does it boil down to , where is 1 staying in memory? If is then it makes sense
and if
Code:
person-name[0] = 0x344832
for example does it boil down to
&0x344832 that really confused me lol..but it is saying where is this address or value stored in memory right? If so I think I get why type is of as is person-name.
But in the case of &1 or &0x344832 for example, how does it know which 1 or 0x344832 it should look for if there were more than one 1's or 0x344832 in memory? Is there some kind of metadata attached to the value or something
Thanks...