如何设置结构的枚举成员的值

时间:2017-08-05 02:58:15

标签: c

给我带来问题的结构代码是

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

枚举是

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

当我尝试设置struct Cell成员的值时,我使用此代码;

 gamer1->Cell = RED;

然而,在编译它时会给我这个错误;

error: 'Gamer' has no member named 'Cell'". Thanks in advanced.

1 个答案:

答案 0 :(得分:7)

你应该gamer1->token = RED; token是结构的成员,而不是Cell