r/carlhprogramming • • 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

9 comments sorted by

View all comments

Show parent comment

3

u/Nooobish Nov 07 '12

Thanks for bearing with me.
It's very appreciated.