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


Groups > comp.lang.c > #67954

Re: programming in c: array; for loop to initialize values

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: programming in c: array; for loop to initialize values
Date 2015-08-21 13:17 -0400
Organization Self
Message-ID <55D75D2F.2000506@verizon.net> (permalink)
References <43dff05d-eda8-4a4d-b9e5-4de3e9e9f21e@googlegroups.com> <f1ad4ae3-94e1-4f09-bd2c-2014ab6c8f2e@googlegroups.com> <lnk2so1rqr.fsf@kst-u.example.com>

Show all headers | View raw


On 08/21/2015 01:22 PM, Keith Thompson wrote:
> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
> [...]
>> It's a bit confusing.
>> Arrays start off with all elements random garbage, unless you tell
>> the compiler differently.
> [...]
> 
> A quibble: it's *arbitrary* garbage, not random garbage.  You can't
> meaningfully predict the initial values of an uninitialized array, but
> if you try to use those values as random numbers it won't turn out well.
> It's even possible that the initial contents will happen to be all zeros.

It's not only possible, but disproportionately likely, because there are
some systems that zero-initialize it by default.

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


Thread

programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-20 10:22 -0700
  Re: programming in c: array; for loop to initialize values "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-08-20 10:29 -0700
    Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-20 11:26 -0700
      Re: programming in c: array; for loop to initialize values "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-08-20 11:37 -0700
      Re: programming in c: array; for loop to initialize values Barry Schwarz <schwarzb@dqel.com> - 2015-08-20 16:47 -0700
        Re: programming in c: array; for loop to initialize values Tim Rentsch <txr@alumni.caltech.edu> - 2015-09-06 13:38 -0700
          Re: programming in c: array; for loop to initialize values Barry Schwarz <schwarzb@dqel.com> - 2015-09-07 12:38 -0700
            Re: programming in c: array; for loop to initialize values Tim Rentsch <txr@alumni.caltech.edu> - 2015-09-07 23:00 -0700
  Re: programming in c: array; for loop to initialize values jt@toerring.de (Jens Thoms Toerring) - 2015-08-20 17:32 +0000
    Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-20 11:27 -0700
  Re: programming in c: array; for loop to initialize values Keith Thompson <kst-u@mib.org> - 2015-08-20 12:44 -0700
    Re: programming in c: array; for loop to initialize values "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-08-20 13:34 -0700
    Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-21 04:03 -0700
  Re: programming in c: array; for loop to initialize values Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-21 02:08 -0700
    Re: programming in c: array; for loop to initialize values Keith Thompson <kst-u@mib.org> - 2015-08-21 10:22 -0700
      Re: programming in c: array; for loop to initialize values James Kuyper <jameskuyper@verizon.net> - 2015-08-21 13:17 -0400
  Re: programming in c: array; for loop to initialize values Alla _ <modelling.data@gmail.com> - 2015-08-21 04:07 -0700

csiph-web