Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Program to print the longest line Date: Wed, 18 Nov 2015 09:24:27 -0800 Organization: None to speak of Lines: 53 Message-ID: References: <8a605c3e-2e2d-456f-bcf4-f23bf4c40bc2@googlegroups.com> <17df1fa8-6093-4ea6-8c69-6bfaf27aa73b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="23269"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LYU20GcE3RSTLaY0bI+i9" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:tfNtii+RkVPBhHj5+HpltSjdTJg= sha1:cOeBip+Jj/7UzdwzpAER1ZI5rw4= Xref: csiph.com comp.lang.c:76429 Malcolm McLean writes: > On Wednesday, November 18, 2015 at 4:49:24 PM UTC, Keith Thompson wrote: [...] >> That's very close to being correct. >> >> The array is not *empty*. Each of its elements has a value from the >> moment the array is created. In the absence of any initialization, that >> value just happens to be garbage. A 1000-element array of char always >> holds 1000 char values. >> > C programmers misuse the term "array". No, most of us don't, but you do. [...] > But in C we don't make much of a distinction between memory with garbage > in it and memory with data. Correct. For example, int n; defines an object `n` of type int. It is an int object whether a value has been stored in it or not. Exactly the same thing applies to objects of array type. > So int square[10][10]; creates 100 > integers, initialised to garbage values. It actually an error to try > to read them, but few compilers enforce that. To be precise, it's undefined behavior. > If you set the values to 1 .. 100 then of course you have an > array. Now the values mean something. You are introducing needless confusion. If you want to talk about initialized array objects vs. uninitialized array objects, either use those terms (preferable) or invent your own. Pretending that an uninitialized array object is not an "array" is not useful, and I suggest you stop spouting such nonsense in the presence of novice C programmers. (If you can cite a reliable source that says an array object isn't an "array" until it's been initialized, I'd be interested in seeing it -- but it still wouldn't affect the correct terminology used when discussing C.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org 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"