Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #75203

Re: Funny C Program

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Funny C Program
Date 2015-11-06 17:12 -0800
Organization None to speak of
Message-ID <lnr3k21ujq.fsf@kst-u.example.com> (permalink)
References <e1367c64-92c8-4c2e-abb1-0ebf2c27bce7@googlegroups.com> <24250e2c-bcdd-4425-a730-433ffc6f89e0@googlegroups.com> <87ziyqtybf.fsf@bsb.me.uk>

Show all headers | View raw


Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> jimzhou001@gmail.com writes:
>> Actually I have another question,"Is 'int monk[101]={0};' really
>> legal?
>
> Yes, it's fine.
>
> <snip>

To expand on that: If an initializer doesn't specify values for all
elements of the object being initialized, the unspecified elements are
initialized to zero.  (That's 0 for integers, 0.0 for floating-point,
NULL for pointers.)

{0} is a valid initializer for any type, and will recursively set every
element to zero.  (It would have been nice to be able to write {} and
let *all* the elements be set implicitly, but the language doesn't allow
it.)

Some compilers, including older versions of gcc, might warn about
missing initializers.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Funny C Program jimzhou001@gmail.com - 2015-11-03 17:54 -0800
  Re: Funny C Program bartekltg <bartekltg@gmail.com> - 2015-11-04 05:28 +0100
    Re: Funny C Program Richard Heathfield <rjh@cpax.org.uk> - 2015-11-04 07:12 +0000
      Re: Funny C Program bartekltg <bartekltg@gmail.com> - 2015-11-04 13:25 +0100
        Re: Funny C Program bartekltg <bartekltg@gmail.com> - 2015-11-04 13:52 +0100
          Re: Funny C Program jimzhou001@gmail.com - 2015-11-04 06:36 -0800
    Re: Funny C Program jimzhou001@gmail.com - 2015-11-04 02:28 -0800
      Re: Funny C Program bartekltg <bartekltg@gmail.com> - 2015-11-04 13:25 +0100
    Re: Funny C Program Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-04 19:07 -0800
      Re: Funny C Program bartekltg <bartekltg@gmail.com> - 2015-11-05 09:48 +0100
        Re: Funny C Program Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-05 06:08 -0800
  Re: Funny C Program Richard Heathfield <rjh@cpax.org.uk> - 2015-11-04 07:04 +0000
    Re: Funny C Program jimzhou001@gmail.com - 2015-11-04 02:33 -0800
      Re: Funny C Program Richard Heathfield <rjh@cpax.org.uk> - 2015-11-04 10:57 +0000
        Re: Funny C Program jimzhou001@gmail.com - 2015-11-04 03:46 -0800
          Re: Funny C Program luser droog <luser.droog@gmail.com> - 2015-11-04 10:46 -0800
            Re: Funny C Program jimzhou001@gmail.com - 2015-11-04 15:14 -0800
  Re: Funny C Program brian.oakley@stonybrook.edu - 2015-11-04 12:37 -0800
    Re: Funny C Program jimzhou001@gmail.com - 2015-11-04 15:30 -0800
  Funny C Program jimzhou001@gmail.com - 2015-11-06 16:40 -0800
    Re: Funny C Program Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-07 01:04 +0000
      Re: Funny C Program Keith Thompson <kst-u@mib.org> - 2015-11-06 17:12 -0800
        Re: Funny C Program jimzhou001@gmail.com - 2015-11-06 18:47 -0800
          Re: Funny C Program James Kuyper <jameskuyper@verizon.net> - 2015-11-07 11:24 -0500
            Re: Funny C Program jimzhou001@gmail.com - 2015-11-07 16:21 -0800
              Re: Funny C Program Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-08 00:46 +0000
              Re: Funny C Program James Kuyper <jameskuyper@verizon.net> - 2015-11-07 19:56 -0500
                Re: Funny C Program jimzhou001@gmail.com - 2015-11-07 19:08 -0800
                Re: Funny C Program James Kuyper <jameskuyper@verizon.net> - 2015-11-08 10:58 -0500
                Re: Funny C Program James Kuyper <jameskuyper@verizon.net> - 2015-11-12 13:31 -0500
                Re: Funny C Program Keith Thompson <kst-u@mib.org> - 2015-11-12 11:59 -0800
                Re: Funny C Program jimzhou001@gmail.com - 2015-11-17 23:00 -0800
                Re: Funny C Program jimzhou001@gmail.com - 2015-11-18 00:12 -0800
                Re: Funny C Program Keith Thompson <kst-u@mib.org> - 2015-11-18 09:01 -0800
                Re: Funny C Program jimzhou001@gmail.com - 2015-11-17 23:00 -0800
    Re: Funny C Program James Kuyper <jameskuyper@verizon.net> - 2015-11-06 20:07 -0500

csiph-web