[OCLUG-devel] Initializing Strings
Doug Jolley
ddjolley at gmail.com
Thu Sep 8 10:59:54 PDT 2005
I have a textbook on C that says that in the case of this declaration:
char string1[40] = "Doug";
a terminating null character is automatically added by the compiler. That
doesn't seem to be the case; and, I would hope that it's not. I see the
above being a simple declaration of an array of characters which may not be
a string.
OTOH, I would be quite happy if the compiler automatically appended a null
character in this case:
char string2[] = "Doug";
I think the shorthand syntax above should be applied strictly to strings and
therefore the automatic addition of the terminating null character would be
appropriate.
Anyway, my question is, in the first case, is my textbook wrong and there is
no automatically supplied null character? As I said, that appears to be the
case and I hope that it is -- or, am I missing something?
Thanks for any input.
... doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://localhost.localdomain/pipermail/oclug-devel/attachments/20050908/cdf31710/attachment.html
More information about the OCLUG-devel
mailing list