The problem is your initialization at the beginning of main. I can't fix it cuz I'm completely lost as to what you're doing w/that, but it has to do w/your struct initialization--it's incorrect. On 11/5/07, John Miller <n1umj@xxxxxxxxxxx> wrote: > Well, as I work on my last homework assignment, with what I think is huge > progress, I find myself with yet another question though I think this is > something simple like last week's. I'll do like last week, I'll post the > code in here and comment where the error points to, if some one can tell me > what's up there, or if I'm just getting lucky in only having 2 errors or > what. It looks like I only have 2 errors though, and I think this is 1 where > if I fix one I fix both but I am stuck because when I do what it suggests I > do, I come up with 27 errors so apparently either that's wrong, or I am > wrong and happened to stumble in to a way with very few errors. It's in the > error checking portion of the program so I probably could just cut that out > since I have no clue when that came about anyway, but I'm so close I hate to > do that. Anyway, the code follows and then the errors. > > (start code) > #include <stdio.h> > > #define DATA_SETS 5 > > #define STD_HOURS 40.0 > > #define OT_RATE 1.5 > > > > /****************************************/ > > /* Structure Declarations */ > > /****************************************/ > > struct employee /* Structure to store associate data */ > > { > > char name[20]; /*employee names*/ > > long id_number; /* Member: Stores Clock ID Number */ > > float wage; /* Member: Stores hourly wage */ > > float hours; /* Member: Stores number of hours worked */ > > float overtime; /* Member: Stores number of overtime hours worked */ > > float gross; /* Member: Stores gross pay */ > > struct employee *next; > > }; > > > > /************************************************************************/ > > /* Function: input_hours_worked */ > > /* */ > > /* Purpose: Obtains input from user, the number of hours worked for */ > > /* each employee based on clock number. The number of */ > > /* hours worked are passed back to 'main', where they are */ > > /* assigned to the array hours_worked. */ > > /* */ > > /* Parameters: n - Data set #. */ > > /* clock - Employee's clock number */ > > /* */ > > /* Returns: hours: The number of hours worked. */ > > /* */ > > /************************************************************************/ > > float input_hours_worked ( int n, int clock ) > > { > > /* Local Declarations */ > > float hours; /* Number of hours worked by employee */ > > float hours_in_a_week = 168.0; /* Max hours in a work week */ > > printf ( "\n" ); > > printf ( "Data Set #%i\n", n + 1 ); > > printf ( "Clock Number: %06i\n", clock ); > > printf ( "Enter Hours Worked: " ); > > scanf_s ( "%f", &hours ); /* Read in the number of hours worked */ > > /* Test for user error */ > > if( ( hours >= 0.0 ) && ( hours < hours_in_a_week ) ) > > return hours; /* Return the number of hours worked */ > > else > > return ( -1.0 ); /* Return Error */ > > } /* End of input_hours_worked function */ > > > > /************************************************************************/ > > /* Function: calculate_overtime_hours */ > > /* */ > > /* Purpose: Calculate the amount of overtime worked based on a 40 */ > > /* hour work week. */ > > /* */ > > /* Parameters: hours - Number of hours worked */ > > /* */ > > /* Returns: A value equal to the number of overtime hours worked. */ > > /* If no overtime was worked, then 0.0 is returned. */ > > /* */ > > /************************************************************************/ > > float calculate_overtime_hours ( float hours ) > > { > > /* Calculate Overtime Hours */ > > if( hours > STD_HOURS ) > > return ( hours - STD_HOURS ); /* Return the amount of overtime worked */ > > else > > return ( 0.0 ); /* Return that no overtime was worked */ > > } /* End calculate_overtime function */ > > > > /************************************************************************/ > > /* Function: calculate_gross_pay */ > > /* */ > > /* Purpose: Calculate the total gross pay based on the amount of */ > > /* time that was worked. This includes overtime pay, if */ > > /* applicable. */ > > /* */ > > /* Parameters: ot - Overtime hours worked */ > > /* hours - Regular hours worked */ > > /* wage_per_hour - Hourly wage for employee */ > > /* */ > > /* Returns: Returns a value that is equal to the gross pay due to */ > > /* the employee. */ > > /* */ > > /************************************************************************/ > > float calculate_gross_pay ( float ot, float hours, float wage_per_hour ) > > { > > if( ot > 0 ) > > return ( wage_per_hour * ( STD_HOURS + ( ot * OT_RATE ) ) ); > > else > > return ( wage_per_hour * hours ); > > } /* End calculate_gross_pay function */ > > > > /************************************************************************/ > > /* Function: display_wage_data */ > > /* */ > > /* Purpose: To display all employee information to the screen. */ > > /* */ > > /* Parameters: worker - Array of structures with all employee info */ > > /* size - number of array elements to process */ > > /* */ > > /* Returns: Nothing. */ > > /* */ > > /************************************************************************/ > > > > void print_list(emp1) > > 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 (remember null is 0 or false) */ > > void display_wage_data ( struct employee worker[], int size ); > > { > > /* Local Declarations */ > > int n; /* loop and array index */ > > /* Print out header */ > > printf ( "\n\n" ); > > printf ( "---------------------------------------------------\n" ); > > printf ( "Clock#\t Wage Hours\t OT\t Gross \n" ); > > printf ( "---------------------------------------------------\n" ); > > /* Print data for each employee */ > > for( tmp=emp1; tmp; tmp = tmp->next) > > { > > printf ( "%06i\t%5.2f\t%4.1f\t%4.1f\t%6.2f\n", > > tmp->id_number, > > tmp->wage, > > tmp->hours, > > tmp->overtime, > > tmp->gross ); > > } /* End for loop */ > > } /* End display_wage_data function */ > > > > /************************************************************************/ > > /* Function: error_check */ > > /* Purpose: To report any error to the user. */ > > /* */ > > /* Parameters: hours - Hours entered by user */ > > /* */ > > /* Returns: Nothing. */ > > /* */ > > /************************************************************************/ > > void error_check (float hours) > > { > > /* see if error condition on hours exists */ > > if( hours == -1.0 ) > > { > > printf ( "An invalid entry has been made.\n" ); > > printf ( "Please start over.\n" ); > > exit (1); > > } /* End of if statement */ > > } /* End error_check function */ > > > > /*****************/ > > /* MAIN */ > > /*****************/ > > main() > > { > > char answer[80]; > > int more_data = 1; > > char value; > > /* Local Declarations */ > > struct employee *current_ptr, associated_data_sets = /* Array of structures > storing */ > > /* all associate data */ > > *head_ptr; /* always points to first node */ > > { > > { > > "Connie Cobol", 98401, 10.60, 0, 0, 0 > > } > > , > > { > > "Mary Apl", 526488, 9.75, 0, 0, 0 > > } > > , > > { > > "Frank Fortran", 765349, 10.50, 0, 0, 0 > > } > > , > > { > > "Jeff Ada", 34645, 12.25, 0, 0, 0 > > } > > , > > { > > "Anton Pascal", 127615, 8.35, 0, 0, 0 > > } > > > }; > > int n; /* Loop Counter */ > > /* Introduce User to program */ > > printf ( "WAGE CALCULATOR\n" ); > > printf ( "Please input the number of Hours Worked for each Employee(ie. > Clock Number)\n" ); > > /* Loop for inputting and processing wage data */ > > for( n=0; n < DATA_SETS; ++n ) > > { > > associate[n].hours = input_hours_worked ( n, associate[n].id_number ); > > error_check ( associate[n].hours ); > > associate[n].overtime = calculate_overtime_hours ( associate[n].hours ); > > associate[n].gross = calculate_gross_pay ( associate[n].overtime, > > associate[n].hours, > > associate[n].wage ); > > } /* End of for loop */ > > /* Print out information on employees */ > > display_wage_data ( associate, DATA_SETS ); > > } /* End of Main */ > > (end code) > > Error 3 error C2143: syntax error : missing ';' before 'type' c:\documents > and settings\john miller\my documents\visual studio > 2005\projects\homework8\homework8.c 180 > Error 5 error C2059: syntax error : '}' c:\documents and settings\john > miller\my documents\visual studio 2005\projects\homework8\homework8.c 189 > > > > > Those are errors 3 and 5, the other 3 were warnings that I've had 1 or 2 > pretty much right along and it hasn't hurt anything. > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > > -- Jackie McBride Please join my fight against breast cancer <http://teamacs.acsevents.org/site/TR?px=1790196&pg=personal&fr_id=3489> & Check out my homepage at: www.abletec.serverheaven.net __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind