X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Mok-Kong Shen 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: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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: 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 Precedence: bulk Am 27.08.2011 09:08, schrieb Rod Pemberton: > "Mok-Kong Shen" 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