我现在正在学习枚举和结构,并有一个我无法解决的问题。如果我有一个基本的结构并定义一个员工,我看到我可以执行以下操作。将整数值赋给C中一个struct中的枚举?
我已将员工添加到第一个项目,但是如何让用户输入一个整数然后让该整数为使用嵌套在结构中的枚举分配给Low,Medium或High?谢谢!
struct add {
char employee[255];
enum EmployeeLevel {Low = 0, Medium, High};
};
struct add EMP[10]; //Global variable to add employees using the add struct
printf("Please enter employee name\n");
scanf("%s", EMP[0].employee); //Assigns the user input to the name of the first employee