在数组中引入变量,但是这个变量已经被常属性修饰了,为啥会出现这种情况呢

#include <stdio.h>
int main()
{
const int n= 10;
int arr[n]= {0};
return 0;
}

[Running] cd "d:\C++Projects" && gcc test1.c -o test1 && "d:\C++Projects"test1
test1.c: In function 'main':
test1.c:57:5: error: variable-sized object may not be initialized
int arr[n]= {0};
^~~
test1.c:57:18: warning: excess elements in array initializer
int arr[n]= {0};
^
test1.c:57:18: note: (near initialization for 'arr')

[Done] exited with code=1 in 0.07 seconds

为啥会是这样的情况呢,代码没写错啊

编译器要求数组的大小必须是常数。连常量都不行。
你可以写#define n 10
但const int n = 10不行