sizeof() on constant strings

Andrew Bartlett abartlet at samba.org
Mon Sep 1 23:18:14 MDT 2014


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



-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 339 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140902/5ad31e00/attachment.c>


More information about the samba-technical mailing list