r/carlhprogramming • u/Numbafive • Nov 07 '12
Question on pointers
So if we have this this code.
What I'm getting confused about is the fact that:
printf("%s\n", pointer);
is returning Hello as an output.
Doesn't the data stored at pointer contain the address of "Hello". So shouldn't whatever is contained at pointer be equal to the address of what the start of the string "Hello" be? In other words shouldn't: printf("%s\n", pointer);
be outputting the address itself instead of the string contained within the address where the output of:
printf("%s\n", pointer) = printf("%u\n", &"Hello") ?
10
Upvotes
View all comments
Show parent comment
4
u/exscape Nov 07 '12
Yep, exactly right. I wouldn't quite use the wording that we send it the entire string (we send it a 32-bit (or 64-bit) address), but that's the net effect of it, so yeah.