2014-11-15 2 views
0

Я пишу простую игру с играми с лжецами. К сожалению, у меня возникает проблема, когда я компилирую, говоря, что должен быть «;» и указывая на точечный оператор на структуре, расположенной в одной из моих функций.ожидается ';' в конце объявления - повторное использование оператора точки struct struct

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 
    } 

} 

ответ

2

Изменить

player p1.dice[i] = ((rand() % 6) + 1); 

в

p1.dice[i] = ((rand() % 6) + 1); 
Смежные вопросы