View Single Post
Old 04-23-2008, 02:17 PM   #1 (permalink)
alman9898
Registered User
 
Join Date: Apr 2008
Posts: 1
OS: xp


Constant array size

I know in C, arrays have to of a constant size.

However when I do something like:

const int size = 10;
int list[size];

I get thrown an error that the array size must be a constant expression (at the line where the array is declared). However, when in C++ when I do this it compiles fine. I'm using Visual Studio 2005, by the way.

However, when I switch to "Compile as C++ code" it compiles the .c file correctly. So is this valid for any C code, or just the Visual Studio compiler?

Last edited by alman9898 : 04-23-2008 at 02:47 PM.
alman9898 is offline   Reply With Quote