gpt4 book ai didi

c - 声明末尾预期为 ';' - 重新放置结构成员点运算符

转载 作者:太空宇宙 更新时间:2023-11-04 08:34:21 24 4
gpt4 key购买 nike

我正在编写一个简单的说谎者骰子游戏。不幸的是,我在编译时遇到了一个问题,说应该有一个';'并指向位于我的一个函数中的结构上的点运算符。

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com