(illustrate memories with blocks separated by "|" )
I wrote : char c;//var
Memory : | | char | |
I wrote : char c[2]//array
Memory : | | char | char | | //consecutively ?
I wrote : int f(int,char*);//function
Memory : | | int* | int | char * | //consecutively ?
Do I understand correctly ? case 3 int* is the function pointer ?
And some small questions :
- Case 2 and 3 are consecutive ?
- Case 2 should have some info to tell c contains 2 elements.Where is it ?
- Case 3 should have some info to tell f contains 2 arguments.Where is it ?
In case 2 the array size is not stored anywhere so your answer is correct.
Case 3 is a function declaration and will not allocate any memory at all. Not sure if this is what they are after.