On Wed, Aug 30, 2006 at 08:57:13AM -0400, Chris Littell wrote:
> On 8/30/06, Nikolai Weibull <[EMAIL PROTECTED]> wrote:
> >On 8/29/06, Brad Beveridge <[EMAIL PROTECTED]> wrote:
> >> On 29/08/06, Ilya <[EMAIL PROTECTED]> wrote:
> >> > Brad Beveridge wrote:
> >> > > static char string[2] = {0};
> >> > Should not you have "= {0, 0}" here? Second element never get
> >> > initialized but it could be accessed by ml_append_string.
> >>
> >> That might be more clear perhaps, but when you initialize an array
> >> like that in C, the last element is propagated for the whole array.
> >
> >What C compiler are you using? The last element is /not/ propagated
> >in C. The rest of the array will be initialized to zero, which is the
>
> In C89 this is true. In C99, you can initialize values out of order
> and by index range, and the final value in an array initializer is
> propogated to the rest of the values.
>
> http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gcc/designated-inits.html
Quoting an example from this document:
int a[6] = { [1] = v1, v2, [4] = v4 };
is equivalent to
int a[6] = { 0, v1, v2, 0, v4, 0 };
Which behaves as Nikolai suggested and K&R explains. Any unspecified
elements are initialized to 0.
James
--
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[EMAIL PROTECTED]>
signature.asc
Description: Digital signature
