First, use the previously learned function to edit the system.
Second, the function structure
Staff Information Management System
Begin
1 Search by Employee number
2 According to the Education Inquiry 3 by number inquiry
2 Delete by Employee name
1 Delete by employee number
2 Change by Employee name
1 Change by employee number
Menu
Select a program based on the value entered by the menu
1 Input Staff Information 2 Browse staff information 3 Staff Information 5 Add staff Information 4 Delete staff Information 6 modify staff information
7 exit
Three, the purpose: requires proficiency in C language basic knowledge and editing skills. Basic understanding of the basic ideas and methods of structured programming. Through writing the student's C language Staff information Management system, facilitates the management to the staff's information. Through the design of the staff C language Information management system, the training synthesizes the function's custom, the array, the structure and so on, and enhances the program design ability. Requirements: Design a staff information management system, so that it can provide the following functions:
1, should provide an interface to invoke the various functions, the call interface and the various functions of the operating interface should be
As clear and beautiful as possible!
2, Input function: Employee information input (staff information with file preservation), can be completed at once if
The input of the dry bar record.
3, browsing function: Complete the display of all staff information.
4, find the function: ① completed by the employee's employee number query staff related information, and display.
② completed according to the staff's academic qualifications to inquire about the staff's relevant information, and display. ③ completed by the employee's telephone number to inquire about employee information, and display. 5, delete function: ① by entering the name of the employee to complete the information of the employee to delete.
② the employee by entering the employee number to complete the deletion of the information.
6, add the function: to complete the task of adding new staff information.
7, modify the function: ① by entering the name of the employee to complete the information of the employee to modify. ② by entering the employee number to complete the information of the staff to modify. 8. Exit Employee Information Management system
Four, code
#include
#include
#include
#define N 100
struct employee
{
int num;
Char name[20];
char sex;
int age;
Char xueli[30];
int wage;
Char addr[30];
Char tel[20];
}
EM[100];
void menu ();
void input ();
void save (int);
void display ();
void Del ();
void Add ();
void Search ();
void Search_num ();
void Search_xueli ();
void Search_tel ();
void Modify ();
void Main () {menu ();
int N,flag;
Char A;
Do
{printf ("Please select the steps you need to do (1--7): \ n");
scanf ("%d", &n);
if (n>=1 && n<=7)
{
flag=1;
Break
}
Else
{
flag=0;
printf ("You entered the wrong, please re-select!"); }
}
}
while (flag==0);
while (flag==1)
{switch (n)
{Case 1:printf ("Enter employee information \ n");
printf ("\ n");
Input ();
Break
Case 2:printf ("Browse employee information \ n");
printf ("\ n");
Display ();
Break
Case 3:printf ("Employee information by employee number \ n");
printf ("\ n");
Search ();
Break
Case 4:printf ("Delete employee information \ n");
printf ("\ n");
Del ();
Break Case 5:printf ("Add employee information \ n");
printf ("\ n");
Add ();
Break
Case 6:printf ("Modify employee information \ n");p rintf ("\ n");
Modify ();
Break
Case 7:exit (0); Default:break; }
GetChar ();
printf ("\ n");
printf ("Whether to proceed (Y or N): \ n");
scanf ("%c", &a);
if (a== ' y ') {flag=1;
System ("CLS"); menu ();
printf ("Please re-select the steps you need to do (1--7): \ n");
scanf ("%d", &n);
printf ("\ n");
}
else exit (0);
}
}
void menu ()
{
printf ("************ welcome access to employee information Management System **********\n");
printf ("1. Enter employee Information");
printf ("2. Browse employee information \ n");
printf ("3. Query staff Information");
printf ("4. Delete Employee information \ n");
printf ("5. Add employee Information");
printf ("6. Modify employee information \ n");
printf ("7. Exit \ n");
printf ("******************** Thank you for using ******************\n");
printf ("\ n");
printf ("\ n");
}
void input ()
{
int i,m;
printf ("Please enter the number of employees who need to create information (1--100): \ n");
scanf ("%d", &m);
for (i=0;i
{printf ("Please enter the employee number:");
scanf ("%d", &em[i].num);
printf ("Please enter Name:");
scanf ("%s", em[i].name);
GetChar ();
printf ("Please enter gender (f--female m--male):");
scanf ("%c", &em[i].sex);
printf ("Please enter Age:");
scanf ("%d", &em[i].age);
printf ("Please Enter education:");
scanf ("%s", Em[i].xueli);
printf ("Please enter Salary:");
scanf ("%d", &em[i].wage);
printf ("Please enter your address:");
scanf ("%s", em[i].addr);
printf ("Please enter the phone:");
scanf ("%s", Em[i].tel);
printf ("\ n");
}
printf ("\ n creation completed!\n");
Save (m);
}
void Save (int m)
{
int i; FILE*FP;
if ((Fp=fopen ("Employee_list", "WB")) ==null)
{
printf ("Cannot open file\n");
Exit (0);
}
for (i=0;i
if (fwrite (&em[i],sizeof (struct employee), 1,FP)!=1)
printf ("File Write error\n");
Fclose (FP);
}
Staff management System