Spe*_*cer 1 c arrays constants
我有一个游戏的头文件,声明一个2d数组的板.
#ifndef GAME_H_
#define GAME_H_
static const int columns = 15;
static const int rows = 15;
int board[rows][columns];
#endif /* GAME_H_ */
Run Code Online (Sandbox Code Playgroud)
我收到错误" error: variably modified 'board' at file scope".
C不允许const变量作为数组边界.改为使用枚举:
enum { columns = 15, rows = 15 };
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2056 次 |
| 最近记录: |