#include <stdio.h>
#include <stdlib.h>
#define SIZE 6

struct Employee_type{
    char name[10];
    int age;
    int salary;
} emp[SIZE];

void save() {
    FILE *fp;
    int i;

    // 打开文件 employees.dat，以只写方式打开二进制文件
    fp = fopen("employees.dat", "wb");
    if (fp == NULL) {
        printf("File opening failed！\n");
        exit(0);
    }

    // 使用 for 循环写入员工的信息
    for (i = 0; i < SIZE; i ++) {   
    	if(fwrite(&emp[i],sizeof(struct Employee_type),1,fp)!=1)
    		printf("File write error!\n");
    }

    // 关闭文件
    fclose(fp);
}

int main() {
	int i;
	printf("Please enter data of employees:\n");
	for(i = 0;i<SIZE;i++)
		scanf("%s%d%d",&emp[i].name,&emp[i].age,&emp[i].salary);
	save();
	return 0;
}