char s1[] = "Hello";
the pointer s1 itself probably takes up no space anywhere accesses to the
data are likely to be coded relative to the stack pointer or a register.
this is because the pointer is constant (the data is not, however). Since
where the pointer points can never be changed the compiler doesn't need to
have a place to record it other than code.
char* s2 = "goodbye";
The compiler creates a pointer variable on the stack taking up
sizeof(char*) bytes. What this pointer points to can be changed so the
compiler need a location just in case
s2 = s1; // is legal
s1 = s2; // is not legal
However, the optimizer might recognize that the pointer is never changed
and treat it the same as the s1 case.
>Dan wrote:
>s1 is still a pointer to a character string. The only distinction is that
>when declared as an automatic, s1 points to someplace in the stack (as
>opposed to someplace else in the dynamic heap)
>
>Mitch asks: Where does the s1 pointer exist? I understand it points to an
>address on the stack, but where in memory does the pointer itself live?
>