C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-13-2009, 02:25 PM   #1
Registered User
 
Join Date: May 2009
Posts: 2
C in UNIX environment; external bubble sort doesn't work

Code:
void BubbleSort(EmployeeRecord employees[], int max_employee); //3.12

void BubbleSort(EmployeeRecord employees[], int max_employee) //3.12
{
	int o, i;

	for (o = 0; o < MAX_EMPLOYEE; o++)
	{
		for (i =0; i < MAX_EMPLOYEE - 1; i++)
		{ 
			if (strcmp(employees[i].lastname,employees[i+1].lastname)>0)
			{
				EmployeeRecord tempRec = employees[i];
				employees[i] = employees[i+1];
				employees[i+1] = tempRec;
			}
		}
	}
}
I'm trying to make an external bubble sort that will sort a record of employees. All of that above is my external bubble sort function. I'm still not quite used to using Linux, but I'm using PuTTY to connect to my school's Linux servers and using Pico/GNU nano 1.3.8 to write this. When I gcc it, I get the following errors:

Quote:
sort.c:1: error: expected â)â before âemployeesâ
sort.c:3: error: expected â)â before âemployeesâ
make: *** [sort.o] Error 1
I just can't figure out why I'm getting that error. When I put the function back into the main source file, the sort works fine. As an external function, however, it doesn't work. What did I miss here?

Here's my main source file up until int main(void):

EDIT: "float ........itax" should read "*s_s_itax" without the underscores. I'm guessing a censor is filtering it out.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FEDTAXRATE 0.15
#define STATETAXRATE 0.07
#define SSITAXRATE 0.0775
#define OVERTIME 40
#define FORMAT1 "  %-25s   %5.2f      %7.2f     %7.2f    %7.2f    %6.2f     %7.2f\n"
#define FORMAT2 "                                         %7.2f                %7.2f    %6.2f\n\n"
#define MAX_EMPLOYEE 5

typedef struct EmployeeRecord
{
	char lastname[20+1];
    char firstname[20+1];
	float payrate;
	float hours;
	float defr;
	float net;
	float reg_hours; 
	float ovt_hours;
	float gross;
	float ft, st, ssit;
} EmployeeRecord;

void PrintReportHeadings(FILE * report); //3.1
void InitializeAccumulators(float *tot_payrate,
							float *tot_reghours,
							float *tot_ovthours, 
							float *tot_gross,
							float *tot_fed,
							float *tot_state,
							float *tot_SSI,
							float *tot_defr,
							float *tot_net); //3.2
void InputWorkerData(char *lastname,
					 char *firstname,
					 float *hours,
					 float *payrate,
					 float *defr); //3.3 
float CalcGross (float hours,
				 float payrate); //3.4
void CalcTaxes(float gross,
			   float defr,
			   float *fedtax,
			   float *statetax,
			   float ........itax);	//3.5
float CalcFedTax(float gross,
				 float deferred); //3.5.1
float Calcstatetax(float fedtax); //3.5.2
float CalcSSITax(float gross,
				 float deferred); //3.5.3
void AddDetailToAccumulators(float *tot_payrate,
							 float *tot_reghours,
							 float *tot_ovthours, 
							 float *tot_gross,
							 float *tot_fed, 
							 float *tot_state,
							 float *tot_SSI,
							 float *tot_defr,
							 float *tot_net,
							 float *fedtax,
							 float *statetax,
							 float ........it,
							 float gross,
							 float reg_hours,
							 float ovt_hours,
							 float payrate,
							 float defr); //3.6
extern float CalcNetPay(float gross,
				 float *fedtax,
				 float *statetax,
				 float ........itax,
				 float defr); //3.7
void CalcAverages(float *tot_payrate, 
				  float *tot_reghours, 
				  float *tot_ovthours, 
				  float *tot_gross,
				  float *tot_fed,
				  float *tot_state,
				  float *tot_SSI,
				  float *tot_defr,
				  float *tot_net,
				  FILE * report); //3.8
void PrintTotAvg(float *tot_payrate,
				 float *tot_reghours,
				 float *tot_ovthours, 
				 float *tot_gross,
				 float *tot_fed,
				 float *tot_state,
				 float *tot_SSI,
				 float *tot_defr,
				 float *tot_net,
				 float avg_payrate,
				 float avg_reghours,
				 float avg_ovthours,
				 float avg_gross,
				 float avg_fed,
				 float avg_state,
				 float avg_SSI,
				 float avg_defr,
				 float avg_net,
				 FILE * report); //3.9
void CalcHours(float *hours, 
				float *reg_hours, 
				float *ovt_hours); // 3.10
void PrintEmployeeData(EmployeeRecord employees[],
					   int count_emp,
					   FILE * report); //3.11
extern void BubbleSort(EmployeeRecord employees[], int max_employee); //3.12

Last edited by stn0091; 05-13-2009 at 02:30 PM.
stn0091 is offline   Reply With Quote
Old 05-13-2009, 02:39 PM   #2
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
You're missing the struct, and some #defines.

Since they need to be in both files, look into how to create a header file which both #include
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Old 05-13-2009, 03:25 PM   #3
Registered User
 
Join Date: May 2009
Posts: 2
Thank you. I did as you suggested and it runs fine now.
stn0091 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
bubble sort help. zeromx C Programming 9 10-30-2006 07:37 AM
Array/Structure Bubble Sort JKI C++ Programming 3 09-29-2003 11:59 AM
debug to release modes DavidP Game Programming 5 03-20-2003 03:01 PM
Unresolved external symbols in OGL Shadow12345 Game Programming 4 08-04-2002 09:46 PM
the bubble sort doesn't work help Matt C Programming 2 12-13-2001 06:14 PM


All times are GMT -6. The time now is 01:48 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22