【发布时间】:2018-05-26 18:14:49
【问题描述】:
我正在尝试编写一个简单的 c 程序,但在声明“字符串”数组时遇到了问题。以下代码编译没有错误:
#define HAND_SIZE 10;
int main()
{
char * cards[13] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
int player[HAND_SIZE];
}
但我不能将播放器变成“字符串”数组而不是整数。如果我执行以下任一操作:
char * player[HAND_SIZE];
char player [HAND_SIZE][];
char player [HAND_SIZE][5];
//repeat the above with '= {}' and '= {""}' initializations
我得到错误:
error: expected ‘]’ before ‘;’ token
为什么会发生这种情况,如何在 c 中声明一个空的“字符串”数组?
【问题讨论】:
标签: c arrays initialization declaration