Having a problem trying to pass an array structure to a function.
I'm not sure how to properly define the process. I have other
functions that will need the hours worked passed back too.
#include <stdio.h>
#define total_employees 5
#define over_time_rate 1.5
#define forty_hour_week 40
struct employee
{
int clock_number ; /* clock # */
float hourly_rate ; /* hourly rate of pay */
float hours_worked ; /* hours worked */
float overtime_hours ; /* OT hours worked */
float gross_pay ; /* calc gross pay amount */
float forty_hour_pay ; /* calc gross pay amount for 40 hours */
float overtime_pay ; /* calc gross pay amount for time > 40 hours */
};
struct employee f_input_hours (struct employee[])
{
/* local variable declaration */
int f_counter_one = 0 ; /* variable counter */
/* populate hours worked array */
while ( f_counter_one < total_employees )
/* Prompt for user to input their hours */
printf ("Please enter the total hours worked for clock
number ") ;
printf ("%06i", emp_info_in.clock_number
[f_counter_one] );
printf (": ");
scanf ("%f", &(emp_info_in.hours_worked
[f_counter_one]));
/* increment counter */
++f_counter_one;
}
return(?);
}
main()
{
/* structure array */
struct employee emp_info_in[total_employees] =
{ { 98401, 10.60, 0, 0, 0, 0, 0},
{526488, 9.75, 0, 0, 0, 0, 0},
{765349, 10.50, 0, 0, 0, 0, 0},
{ 34645, 12.25, 0, 0, 0, 0, 0},
{127615, 8.35, 0, 0, 0, 0, 0} },
emp_info_out[total_employees] =
{ { 98401, 10.60, 0, 0, 0, 0, 0},
{526488, 9.75, 0, 0, 0, 0, 0},
{765349, 10.50, 0, 0, 0, 0, 0},
{ 34645, 12.25, 0, 0, 0, 0, 0},
{127615, 8.35, 0, 0, 0, 0, 0} } ;
/********************** begin performed functions ***************************/
/* Explain what we will be processing */
f_explain_message ();
/* perform get hours function */
emp_info_out = f_input_hours (emp_info_in
[total_employees]);