Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set value of an enum member of a structure

Tags:

c

The structure's code that is giving me problems is

typedef struct gamer
{
    char name[MAXNAME];
    Cell token;
    unsigned score;
} Gamer;

The enum is

typedef enum cell
{
    BLANK, RED, CYAN
} Cell;

When I try to set the value of my struct Cell member I use this code;

 gamer1->Cell = RED;

however when compiling it gives me this error;

error: 'Gamer' has no member named 'Cell'". Thanks in advanced.
like image 532
javair peter Avatar asked Mar 08 '23 10:03

javair peter


1 Answers

You should do gamer1->token = RED;

token is the member of the struct and not Cell.

like image 198
Rajeev Ranjan Avatar answered Mar 23 '23 07:03

Rajeev Ranjan