- 分享
- 0
- 人气
- 0
- 主题
- 50
- 帖子
- 710
- UID
- 435780
- 积分
- 4472
- 阅读权限
- 22
- 注册时间
- 2011-8-4
- 最后登录
- 2013-12-3
- 在线时间
- 1158 小时
|
还有3天就是assignment due date我还写不出个所以然,希望有c language的大神愿意指导。
题目:
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;
-
- };
复制代码 目前遇到的问题是, 基本上function1 都用不到,可以compile 可是run program function 1 一个一个data key in 后会当机==
求神人指点~~~ |
|