delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
From: | "Rod Pemberton" <do_not_have AT noavailemail DOT cmm> |
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: | <j3a54s$uc9$1@speranza.aioe.org> |
References: | <j393ip$q9n$1 AT news DOT albasani DOT net> |
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" <mok-kong DOT shen AT t-online DOT de> 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |