I am new to C programming and am trying to quick sort an array of records. I’m not sure if I am sending the Record to the function properly but my error is
error: conversion from “TaxRecord*” to non-scalar type “TaxRecord” requested
error: no match for “operator<” in “*(table + ((unsigned int)(((unsigned int)left) * 104u))) < pivot”
void qsort(TaxRecord table,int start,int finish);
qsort(theEmployees[i],0,i);
void qsort(TaxRecord table[],int start,int finish) {
int left = start,
right = finish;
TaxRecord pivot = table[((start+finish)/2)];
TaxRecord temp = table;
while (left < right) {
// find left candidate
while (table[left] < pivot)
left++;
// find right candidate
while (table[right] > pivot)
right--;
if (left <= right) {
int temp = table[left];
table[left] = table[right];
table[right] = temp;
left++;
right--;
}
} // while left < right
if (start < right)
qsort(table,start,right);
if (left < finish)
qsort(table,left,finish);
}
1) Your function prototype doesn’t match the function declaration.
2) You call the function with what appears to be a single array element instead of the array itself.
3) You attempt to assign an array to a single
TaxRecordvariable.4) You attempt to use an
inttemporary while swappingTaxRecordelements.5) The error message sounds like there isn’t a defined
operator<for yourTaxRecordtype.My suggestion: instead of fixing your code just use the library
qsortorstd::sort, depending on whether this is C or C++.