sizeof() on constant strings

Scott Lovenberg scott.lovenberg at gmail.com
Tue Sep 2 02:12:57 MDT 2014


On Tue, Sep 2, 2014 at 12:18 AM, Andrew Bartlett <abartlet at samba.org> wrote:
> Just a hint I found out the hard way recently:
>
> char *foo = "ba";
> and
> char foo[] = "ba";
> give different results when you do sizeof(foo).  See attached test
> program.
>
> Andrew Bartlett
> --
> Andrew Bartlett
> http://samba.org/~abartlet/
> Authentication Developer, Samba Team  http://samba.org
> Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba
>
>
>

Stupid question, does compiler matter?

-- 
Peace and Blessings,
-Scott.


More information about the samba-technical mailing list