我正在编写一个简单的说谎者骰子游戏。不幸的是,我在编译时遇到了一个问题,说应该有一个';'并指向位于我的一个函数中的结构上的点运算符。
error: expected ';' at end of declaration
struct player p1.dice[i] = ((rand() % 6) + 1);
^
;
我尝试了不同类型的结构声明,但都无济于事。这是使用数组的问题吗?
/Global Variables
int amountCall;
int diceCall;
int fails;
int dice[STARTINGDICE];
//Prototypes
int diceRoll();
void playerTurn();
int playerCreator();
int diceDisplay();
typedef struct
{
int fails;
int dice[STARTINGDICE];
int amountCall;
int diceCall;
}
player;
player p1;
player p2;
int diceRoll()
{
srand(time(NULL));
for (int i = 0; i < (STARTINGDICE - fails); i++)
{
player p1.dice[i] = ((rand() % 6) + 1); <<---- Error
}
}
最佳答案
改变
player p1.dice[i] = ((rand() % 6) + 1);
到
p1.dice[i] = ((rand() % 6) + 1);
关于c - 声明末尾预期为 ';' - 重新放置结构成员点运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26946754/