Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 740|回复: 0
打印 上一主题 下一主题

C language 新手求助

[复制链接]

50

主题

0

好友

4472

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

跳转到指定楼层
1#
发表于 2013-8-24 09:50 PM |只看该作者 |倒序浏览
还有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”).


我写到:
  1. #include<stdio.h>
  2. #include<string.h>
  3. main()




  4. {void addnewstaff ();
  5.         int choice;
  6.         FILE *fPtr=NULL;
  7.         FILE *aptr;
  8.         puts("\t***********************************************");
  9.                 puts("\tMAIN MENU - STAFF INFORMATION SYSTEM");
  10.                 puts("\t***********************************************");
  11.                 puts("\t1.Add New Staff Profile");
  12.                 puts("\t2. Delete Staff Profile");
  13.                 puts("\t3. Export All Profiles to ""output.txt""");
  14.                 puts("\t4. Exit");
  15.                 puts("\t***********************************************");
  16.                 puts("\tPlease enter your option < 1 / 2 / 3 / 4 >:");
  17.                 printf("Choice>> ");
  18.                 scanf("%d",&choice);
  19.                 switch(choice){
  20.                
  21.                 case 1:
  22.                 addnewstaff();
  23.                
  24.                 break;
  25.                
  26.                 case2:
  27.                
  28.                 break;
  29.                
  30.                 case3:
  31.                
  32.                 break;
  33.                
  34.                 case4:
  35.                
  36.                 break;
  37.                
  38.                 default:
  39.                 printf("Option not found.");
  40.                
  41. aptr=fopen("database.txt","w");

  42.                 }
  43.                
  44.        
  45. }

  46. void addnewstaff (){

  47. long int id[10];
  48. char name[15];
  49. char gender[6];
  50. long int phone[11];
  51. char email;
  52. FILE *fptr;
  53. fptr=fopen("test.txt","w");
  54.        
  55.         printf("\nPlease enter the following staff information:\n");
  56.         printf("Staff ID: ");
  57.         scanf("%s",&id);
  58.         printf("Name    : ");
  59.         scanf("%s",&name);
  60.         printf("Gender  : ");
  61.         scanf("%s",&gender);
  62.         printf("Phone   : ");
  63.         scanf("%s",&phone);
  64.         printf("Email   : ");
  65.         scanf("%s",&email);
  66.         printf("Staff Profile saved successfully.\n");
  67.         printf("%s\t%s\t%s\t%s\t%s",id,name,gender,phone,email);
  68.         fclose(fptr);
  69.         main();
  70.         return 0;
  71.        
  72.         };
复制代码
目前遇到的问题是, 基本上function1 都用不到,可以compile 可是run program function 1 一个一个data key in 后会当机==
求神人指点~~~




收藏收藏0
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-12-26 02:44 PM , Processed in 0.094617 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部