![]() |
| | #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;
}
}
}
}
Quote:
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 | |
| | #2 |
| and the hat of vanishing 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 | |
| | #3 |
| Registered User Join Date: May 2009
Posts: 2
| Thank you. I did as you suggested and it runs fine now. |
| stn0091 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |