开发者

Array size in C [duplicate]

开发者 https://www.devze.com 2023-02-18 04:21 出处:网络
This question already has answers here: 开发者_开发技巧 Closed 11 years ago. Possible 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

精彩评论

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