X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Rod Pemberton" Newsgroups: comp.os.msdos.djgpp Subject: Re: Array initialization question Date: Sat, 27 Aug 2011 03:08:00 -0400 Organization: Aioe.org NNTP Server Lines: 49 Message-ID: References: NNTP-Posting-Host: qBjb0U1QTH77eiTXJSCpEw.user.speranza.aioe.org X-Complaints-To: abuse AT aioe DOT org X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.2001 X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Microsoft Outlook Express 6.00.2800.2001 X-Priority: 3 X-MSMail-Priority: Normal Bytes: 1781 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Mok-Kong Shen" wrote in message news:j393ip$q9n$1 AT news DOT albasani DOT net... > I found that lines like > > const int sz=3; > int arr[sz]; > > seem to work well as C code. This is a C99 feature. Two links on VLAs follow. #33 mentions VLAs http://home.datacomm.ch/t_wolf/tw/c/c9x_changes.html There is also a section on VLAs here: http://david.tribble.com/text/cdiffs.htm Both links also cover the C struct hack. > 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}; > On the other hand such initialization lists seem to be ok for codes > running in Visual C++. Is this due to a difference between standards > of C and C++? The second link says: "C++ does not support VLAs" So, I would wonder why VC++ supports VLAs. Rod Pemberton