0

Possible Duplicate:
Non-const declaration of array

My compiler gcc allows

int n = 5;
int a[n];

Other compiler visual c gives error. It says array of size 0 cannot be created. Which compiler is correct?

Community
  • 1
  • 1
jaya
  • 345
  • 4
  • 6

1 Answers1

0

Both are correct... these are compilers... In fact, std C assumes the size of a static array needs to be fixed and set by a constant value. use Define instead, or use malloc for dynamic arrays

CoolStraw
  • 5,282
  • 8
  • 42
  • 64
  • see the other question - std C allows dynamic arrays (surely you are using C99 - 10 years old :)) – mmmmmm Mar 22 '11 at 12:04