For example:
int *p;
int a[2] = {1, 2};
p1 = a;
I was wondering where does c++ store the information of memory space of each element? I mean, when I do this:
cout << p << endl;
I only can get the memory address of that array, there is obviously no information related to the "memory length" of single element. But I think there should be some place that the language can refer to the space of memory space of each element. Since if I go on the call this:
cout << *++p << endl;
I can get the second element of that array no matter what type of element in that array and the corresponding space of memory of single element. The language is able to automatically kind of jump over the certain space memory to get the right start place of the next element and its address.
So, again, my question is: Where is the information of the memory space of element in that array stored? Or is there something like "\0"
at the end of each element to signify the end of one element in that array, so the *++p
is about to get to the next right place?