Initializing arrays of char

Henry Spencer henry at zoo.toronto.edu
Sat Oct 6 03:19:13 AEST 1990


In article <15674 at csli.Stanford.EDU> poser at csli.stanford.edu (Bill Poser) writes:
>This means that the assignment of "12345" to an array of five characters,
>is legal. If K&R2 here reflects the standard, then both initializations
>are legitimate.

It does; they are.

>This seems to me to be a bad idea. Everywhere else, one has to take
>into account the terminating null...
>... Not counting the terminating null here is inconsistent.
>Can anyone explain this decision?

It's a special case because this form of initializer is a special case.
Normally, assigning a string of any length to an array of char would be
illegal.
-- 
Imagine life with OS/360 the standard  | Henry Spencer at U of Toronto Zoology
operating system.  Now think about X.  |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list