structure arrays to functions
I am trying to figure out how this works. So far I thought I understood it and yet it wont compile. ?? (this is only a small piece of the whole program, trying to just get one piece to work at at time) Any suggestion, tip or hints would be appreciated.
[code]
#include <stdio.h>
#define NUM_EMPL 5
#define OVERTIME_RATE 1.5
#define STD_WORK_WEEK 40.000
struct employee
{
unsigned long int clock; /*clock number*/
float wage; /*hourly pay*/
float hours; /*hours worked*/
float overtime; /*overtime hours above 40*/
float total; /*regular 40 hour pay*/
float gross; /*total pay including any overtime*/
};
void get_input (struct employee emp_num[], emp_hrs[])
{
/*Local Variable Declaration */
int count; /* Variable used in loop counter */
/* Loop for number of employees defined in NUM_EMPL */
/* Gets number of employee hours and stores them in an array. */
for (count = 0; count < NUM_EMPL; ++count)
{
printf("Enter Hours for Employee #%lu: ",
emp_num[count].clock);
scanf ("%f", &emp_hrs[count].hours);
}
printf("\n\n\n");
}
main ()
{
struct employee data[NUM_EMPL];
int n;
get_input(data,NUM_EMPL)
for (n = 0, n < NUM_EMPL, n++)
{
printf ("employee clock = %lu employee hours = %f\n", data[n].clock, data[n].hours);
}
retun 0;
}
[code]
sorry did he code code wrong
I am trying to figure out how this works. So far I thought I understood it and yet it wont compile. ?? (this is only a small piece of the whole program, trying to just get one piece to work at at time) Any suggestion, tip or hints would be appreciated.
Code:
#include <stdio.h>
#define NUM_EMPL 5
#define OVERTIME_RATE 1.5
#define STD_WORK_WEEK 40.000
struct employee
{
unsigned long int clock; /*clock number*/
float wage; /*hourly pay*/
float hours; /*hours worked*/
float overtime; /*overtime hours above 40*/
float total; /*regular 40 hour pay*/
float gross; /*total pay including any overtime*/
};
void get_input (struct employee emp_num[], emp_hrs[])
{
/*Local Variable Declaration */
int count; /* Variable used in loop counter */
/* Loop for number of employees defined in NUM_EMPL */
/* Gets number of employee hours and stores them in an array. */
for (count = 0; count < NUM_EMPL; ++count)
{
printf("Enter Hours for Employee #%lu: ",
emp_num[count].clock);
scanf ("%f", &emp_hrs[count].hours);
}
printf("\n\n\n");
}
main ()
{
struct employee data[NUM_EMPL];
int n;
get_input(data,NUM_EMPL)
for (n = 0, n < NUM_EMPL, n++)
{
printf ("employee clock = %lu employee hours = %f\n", data[n].clock, data[n].hours);
}
retun 0;
}