c++ question

Russel Caldwell caldr704 at gmail.com
Fri Sep 22 18:11:07 MDT 2006


When I do cout << &foo[0], I get "Hello". Why is that?

On 9/22/06, Steve <smorrey at gmail.com> wrote:
>
> In that case &foo would be &foo[0] it's implied
>
> On 9/22/06, Russel Caldwell <caldr704 at gmail.com> wrote:
> > Here's what's confusing me. If I create a integer array I will get the
> > following:
> >     int foo[10] = {1, 2, 3};
> >
> >     cout << &foo;      //gives me the address foo
> >     cout << foo;        //gives me the address of of foo[0]
> >
> > If I create a character array:
> >    char foo[] = "Hello";
> >
> >     cout << &foo;      //gives me the address of foo
> >     cout << foo;        //gives me the string stored in foo
> >     What will give me the address of foo[0]?
> >
> > /*
> > PLUG: http://plug.org, #utah on irc.freenode.net
> > Unsubscribe: http://plug.org/mailman/options/plug
> > Don't fear the penguin.
> > */
> >
>
> /*
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
> */
>



More information about the PLUG mailing list