I am getting this error when the linked list pointer passes through the calc_gross function. Not sure why?
Code:
error:
warning in function calc_gross
parse error at the end of input
here is my program:
Code:
#include <stdio.h>
#include <stdlib.h>
#define OVERTIME_RATE 1.5
#define STD_WORK_WEEK 40.000
struct employee
{
char name[20]; /*name*/
unsigned long int clock; /*clock number*/
float wage; /*hourly pay*/
float hours; /*hours worked*/
float overtime; /*overtime hours above 40*/
float gross; /*total pay including any overtime*/
struct employee *next;
};
void header (void)
{
/* Explain what program is going to do */
printf ("To find out the gross pay of your employees,\n");
printf ("input the name and hours worked at the clock# prompts.\n");
printf ("\n");
}
void print_list(struct employee *emp1)
{
struct employee *tmp; /* tmp pointer value to current node */
int i = 0; /* counts the nodes printed */
printf ("\n");
printf ("__________________________________________________________________________\n");
printf ("Employee Name\tClock #\t Wage\t Hours\t OT\t Gross\n");
printf ("__________________________________________________________________________\n");
/* Start a beginning of list and print out each value */
/* loop until tmp points to null */
for(tmp = emp1; tmp ; tmp = tmp->next)
{
i++;
printf ("%s\t%06lu\t%7.2f\t%7.2f\n", tmp->name, tmp->clock,
tmp->wage, tmp->hours);
}
printf ("\n\n");
}
void get_hours (struct employee *emp1)
{
struct employee *tmp; /* tmp pointer value to current node */
int i = 0; /* counts the nodes printed */
/* Start a beginning of list and print out each value */
/* loop until tmp points to null */
for(tmp = emp1; tmp ; tmp = tmp->next)
{
i++;
printf("\nFor Employee #%06lu: ", tmp->clock);
printf("Enter Hours Worked ");
scanf ("%f", &tmp->hours);
}
printf("\n\n");
}
void calc_gross (struct employee *emp1)
{
/*Local Variable Declaration */
struct employee *tmp; /* tmp pointer value to current node */
int i = 0; /* counts the nodes printed */
float ot_wage; /*Variable for overtime wages only */
float total; /*Variable used to get the total or regular hours before overtime added */
/* Start a beginning of list and print out each value */
/* loop until tmp points to null */
for(tmp = emp1; tmp ; tmp = tmp->next)
{
i++;
/* calculate gross pay including testing for overtime hours using if-else-if statement */
/* use the DEFINE for STD_WORK_WEEK and OVERTIME_RATE*/
/* pull the hours collected from get_input with emp_hours[] array*/
if (tmp->hours > STD_WORK_WEEK)
{ (tmp->overtime = tmp->hours - STD_WORK_WEEK);
(total = tmp->wage * STD_WORK_WEEK);
(ot_wage = tmp->wage * OVERTIME_RATE);
(tmp->gross = ot_wage * tmp->overtime + total);
}
else if (tmp->hours <= STD_WORK_WEEK)
{ (tmp->overtime = 0);
(tmp->gross = tmp->wage * tmp->hours);
}
}
int main ()
{
char answer[5];
int more_data = 1;
char value;
char first_name[10], last_name[10];
/* Function to call header. */
header ();
struct employee *current_ptr, /* pointer to current node */
*head_ptr; /* always points to first node */
/* Set up storage for first node */
head_ptr = (struct employee *) malloc (sizeof(struct employee));
current_ptr = head_ptr;
while (more_data)
{
printf("\nFirst Name ");
scanf ("%s", first_name);
printf("Last Name ");
scanf ("%s", last_name);
strcpy(current_ptr->name, first_name);
strcat(current_ptr->name, " ");
strcat(current_ptr->name, last_name);
printf ("Enter Employee Clock Number: ");
scanf ("%lu", ¤t_ptr->clock);
printf ("Enter Employee Wage: ");
scanf ("%f", ¤t_ptr->wage);
printf("\nWould you like to add another employee? (y/n): ");
scanf("%s", answer);
/* Ask user if they want to add another employee */
if (value = toupper(answer[0]) != 'Y')
{
current_ptr->next = (struct employee *) NULL;
more_data = 0;
}
else
{
/* set the next pointer of the current node to point to the new node */
current_ptr->next = (struct employee *) malloc (sizeof(struct employee));
/* move the current node pointer to the new node */
current_ptr = current_ptr->next;
}
}
/* Function call to output results to the screen in table format using struct */
get_hours (head_ptr);
calc_gross (head_ptr);
print_list (head_ptr);
system("PAUSE");
return 0;
}