0

For char[size], is it true that size must be constant?

Or say,will it work ?

int length;
...

char[length] arr;

Sorry,don't have the environment here so can't try it myself.

wamp
  • 5,789
  • 17
  • 52
  • 82

1 Answers1

1

Pre C99, yes; the size of an array must be a constant integral expression. C99, however, adds Variable Length Arrays (VLA's), which allow an array to have a dynamic size.

GManNickG
  • 494,350
  • 52
  • 494
  • 543
  • If it works in C99,what's different from `malloc` ?Or say,what's different between heap and stack for C99? – wamp Oct 09 '10 at 08:11