# 已聘用救生員 在原有的hire person代碼上加上了寫入文字檔的功能 ```c= #ifndef HIREPERSON_H_INCLUDED #define HIREPERSON_H_INCLUDED #include <stdio.h> #include <string.h> #include "functions.h" void hirePerson(Member members[]) { int id; char name[80]; printf("Enter the number of the person you want to hire: "); scanf("%d", &id); getchar(); printf("Enter the name of the person you want to hire: "); fgets(name, sizeof(name), stdin); name[strcspn(name, "\n")] = 0; for (int i = 0; i < MAX_MEMBERS; i++) { if (members[i].id == id) { members[i].hired = 1; strcpy(members[i].name, name); break; } } FILE *fp; if ((fp = fopen ("output.txt", "w")) == NULL) { printf("Open File ERROR!\n"); } else{ fprintf(fp, "%d, %d, %s\n", members[id].id, members[id].hired, members[id].name); fclose(fp); } } #endif ``` ![](https://hackmd.io/_uploads/H1enk0Dw2.png) ![](https://hackmd.io/_uploads/ByxEm0PP3.png)