0

I've written the Struct Employee and Enum Education. I am going to use "fwirte()" and "fread()" to write and read the file "emp.dat". But because of the enum, I don't know how to handle it. (Every time you enter a structure variable, it needs to be stored in a file through a linked list.)

#include <stdio.h>
#include <string.h>
enum Education{
    xiaoxue=0,
    chuzhong,
    gaozhong,
    zhuanke,
    benke,
    yanjiusheng
};
struct Employee
{
    char no[7];
    char name[10];
    char sex[2];
    struct date{
        int year;
        int mouth;
        int day;
    }birth;
    enum Education education;
    float salary;
    char telephone[12];
    struct Employee *next;
};

Employee information includes employee number, name, gender, date of birth (structure type, display format 2001/01/02), education (enumeration type: 0-primary school(xiaoxue), 1-junior high school(chuzhong), 2-high school(gaozhong), 3-speciality(zhuanke), 4-Undergraduate(benke), 5-Graduate(yanjiusheng)), salary, telephone, etc. (unique employee number, 6-digit string).

Now I want to write a function. This function first creates an employee variable through keyboard input, and then saves it in a file through "fwrite()". Every time an employee variable is entered, it will be added to the file through the linked list.

When I tried to complete it, the key thing that bothered me was that I didn't know how to assign a value to the Enum property of the structure variable.

Thanks for your help!

Zach Young
  • 23
  • 1
  • 1
  • 5

0 Answers0