By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,082 Members | 2,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,082 IT Pros & Developers. It's quick & easy.

Employee Program problem only part

P: 1
I am doing a likned list program in C.
I am not really good at it and just started. But I am stuck how to pass structure in the function correctly.

this is the driver file
Expand|Select|Wrap|Line Numbers
  1. #ifndef DRIVER_C
  2. #define DRIVER_C
  3. #include "constants.c"
  4. int main(void)
  5. {
  6.   struct employee *startPtr = NULL;
  7.  
  8.   FILE *fileptr= fopen("hw3Employees.dat","r");
  9.   employee only;
  10.  
  11.   getvalues( only, *fileptr);
  12.  
  13.   //insert(&startPtr, fname[],lname[],middle[],id,title[],balance);
  14.     return 0;
  15. }
  16. //void insert(struct employee **sPtr, char fname[],char lname[],char middle[],int id,char title[], int balance)
  17. //{
  18. //return;
  19. //}
  20.  
  21. void getvalues(struct employee *only,FILE ** fileptr)
  22. {
  23.  
  24.     fscanf(*fileptr,"%s%s%s%d%s%d%x",only.fname,
  25.                 only.lname,
  26.                 only.mname,
  27.                 &(only.id),
  28.                 only.title,
  29.             &(only.Balance);
  30.         printf("%s %s   %s    %d    %s    %d  %x\n",only.fname,
  31.             only.lname,
  32.             only.mname,
  33.             only.id,
  34.             only.title,
  35.         only.Balance);
  36. return;
  37.  
  38. }
  39. #endif
  40.  
and the constants file
Expand|Select|Wrap|Line Numbers
  1. #ifndef CONSTANTS_C
  2. #define CONSTANTS_C
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #define ARRAY_SIZE 5
  6. #define ZEROI 0
  7. #define ZEROD 0.00
  8. #define NAME_LEN 30
  9.  
  10. typedef struct {
  11.         char fname[NAME_LEN];  //first name
  12.         char lname[NAME_LEN];  //last name
  13.         char mname[2];
  14.         int id;
  15.         char title[NAME_LEN];
  16.         int Balance;
  17.         struct employee *nextPtr;
  18. }employee;
  19.  
  20. void insert(struct employee **sPtr, char[],char[],char[],int,char[],int);
  21. void getvalues(struct employee*,FILE **);
  22. #endif
  23.  
...I am currently working on the getvalues and it does not seem to be working? Can anyone help?
Mar 25 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.