1 #define MAXN 10010 //1
3 const int MAXN=10010;//2
4
7 int ansTable[MAXN];

若用2的方式,则用gcc编译会出现Error: variably modified 'users' at file scope

改成1的形式,则没有报错信息。

在c里静态数组(固定长度的数组,即LISTEN_NUM位置是常数)是允许的,而动态数组(譬如给数组的长度是用变量来表示的)不能写成 UserProfile users[LISTEN_NUM];形式的,只能自行分配内存。

相关文章:

  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-11-06
  • 2021-08-22
  • 2022-12-23
  • 2021-08-10
相关资源
相似解决方案