如何设置结构的枚举成员的值
发布时间:2020-12-16 10:07:26 所属栏目:百科 来源:网络整理
导读:给我带来问题的结构代码是 typedef struct gamer{ char name[MAXNAME]; Cell token; unsigned score;} Gamer; 枚举是 typedef enum cell{ BLANK,RED,CYAN} Cell; 当我尝试设置我的struct Cell成员的值时,我使用此代码; gamer1-Cell = RED; 但是在编译它时会
给我带来问题的结构代码是
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. 解决方法
你应该做gamer1-> token = RED; token是结构的成员而不是Cell.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |