题目:
Design and write a complete user friendly menu driven C program to serve as Staff Information System for a company. The program saves all records to a database file (i.e. database.dat). If the database file cannot be read, an error message should be printed to notify the user.
The program should allow the user to add, delete the staff profile according to the user’s option. In addition, the program should be able to export all staff profiles to an output text file (i.e. “output.txt”).
我写到:
- #include<stdio.h>
- #include<string.h>
- main()
- {void addnewstaff ();
- int choice;
- FILE *fPtr=NULL;
- FILE *aptr;
- puts("\t***********************************************");
- puts("\tMAIN MENU - STAFF INFORMATION SYSTEM");
- puts("\t***********************************************");
- puts("\t1.Add New Staff Profile");
- puts("\t2. Delete Staff Profile");
- puts("\t3. Export All Profiles to ""output.txt""");
- puts("\t4. Exit");
- puts("\t***********************************************");
- puts("\tPlease enter your option < 1 / 2 / 3 / 4 >:");
- printf("Choice>> ");
- scanf("%d",&choice);
- switch(choice){
-
- case 1:
- addnewstaff();
-
- break;
-
- case2:
-
- break;
-
- case3:
-
- break;
-
- case4:
-
- break;
-
- default:
- printf("Option not found.");
-
- aptr=fopen("database.txt","w");
- }
-
-
- }
- void addnewstaff (){
- long int id[10];
- char name[15];
- char gender[6];
- long int phone[11];
- char email;
- FILE *fptr;
- fptr=fopen("test.txt","w");
-
- printf("\nPlease enter the following staff information:\n");
- printf("Staff ID: ");
- scanf("%s",&id);
- printf("Name : ");
- scanf("%s",&name);
- printf("Gender : ");
- scanf("%s",&gender);
- printf("Phone : ");
- scanf("%s",&phone);
- printf("Email : ");
- scanf("%s",&email);
- printf("Staff Profile saved successfully.\n");
- printf("%s\t%s\t%s\t%s\t%s",id,name,gender,phone,email);
- fclose(fptr);
- main();
- return 0;
-
- };
求神人指点~~~



