我現在正在學習枚舉和結構,並有一個我無法解決的問題。如果我有一個基本的結構並定義一個員工,我看到我可以執行以下操作。將整數值賦給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