开发者

Array size in C [duplicate]

This question already has answers here: 开发者_开发技巧 Closed 11 years ago.

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜