delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2011/08/27/04:15:10

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Mok-Kong Shen <mok-kong DOT shen AT t-online DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Array initialization question
Date: Sat, 27 Aug 2011 09:58:23 +0200
Organization: albasani.net
Lines: 30
Message-ID: <j3a807$aj4$1@news.albasani.net>
References: <j393ip$q9n$1 AT news DOT albasani DOT net> <j3a54s$uc9$1 AT speranza DOT aioe DOT org>
Mime-Version: 1.0
X-Trace: news.albasani.net UqQViUSWKRAstwS9tG0nLEZK/zzSt8IpwRX44NIWJ+TN1Z/kB6QYrNM+74F3JHbrBzwz2dVSjX6NhAKXxAId8cy4ZwU0+mAH9BqylNpGaqeoOMqQtyIU4IsGEMntg5+X
NNTP-Posting-Date: Sat, 27 Aug 2011 07:56:55 +0000 (UTC)
Injection-Info: news.albasani.net; logging-data="DnlcsI2KbFNhPltfvlC8Qss3govOU9cn+uaqlMEfxbjmium8aF9G6QfJqkQGLRGxXaK9o3DiwyWQ2RPhJjNzVmct1esZOstldfINsztQ3OzPMgd4zZajFyhN0Ex+GyQ1"; mail-complaints-to="abuse AT albasani DOT net"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0
In-Reply-To: <j3a54s$uc9$1@speranza.aioe.org>
Cancel-Lock: sha1:z3CiUTurLRdAHkzeEhquOYLSwIc=
Bytes: 2161
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Am 27.08.2011 09:08, schrieb Rod Pemberton:
> "Mok-Kong Shen"<mok-kong DOT shen AT t-online DOT de>  wrote:

>> However I can't have an initialization list
>> e.g.
>>
>>     int arr[sz]={ 0,1,2 };
>>
>
> Why would you need a variable-length array with a fixed quantity of array
> items?  Does that make sense to you?
>
> Is there something wrong with:
>
>    int arr[3]={0,1,2};

My C knowledge is very meagre. Since I have

   const int sz=3;

doesn't this mean that the array "int arr[sz]" has a constant, hence
fixed, size? Certainly not shown in my tiny example, my original
intention was not to provide a complete intialization list, but only
a certain fixed leftmost portion, with the rest to be done via code.
(The leftmost portion has certain characteristics not shared by the
rest of the elements of the array, so it is convenient to specify them
individually in the initialization list.)

M. K. Shen

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019