I know that an array decays to a pointer, such that if one declared
char things[8];
and then later on used things
somewhere else, things
is a pointer to the first element in the array.
Also, from my understanding, if one declares
char moreThings[8][8];
then moreThings
is not of type pointer to char but of type "array of pointers to char," because the decay only occurs once.
When moreThings
is passed to a function (say with prototype void doThings(char thingsGoHere[8][8])
what is actually going on with the stack?
If moreThings
is not of pointer type, then is this really still a pass-by-reference? I guess I always thought that moreThings
still represented the base address of the multidimensional array. What if doThings
took input thingsGoHere
and itself passed it to another function?
Is the rule pretty much that unless one specifies an array input as const
then the array will always be modifiable?
I know that the type checking stuff only happens at compile time, but I'm still confused about what technically counts as a pass by reference (i.e. is it only when arguments of type pointer are passed, or would array of pointers be a pass-by-reference as well?)
Sorry to be a little all over the place with this question, but because of my difficulty in understanding this it is hard to articulate a precise inquiry.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…