I revamped the code and now I'm not getting errors, but it still won't work. On my line where I say partid1 > partid2, partid1 = PS1115 and partid2 = YY7777 and still it says that partid1 is greater than partid2. Here is my code.
Help...
Code:
void sortindex(int index_c)
{
int i, pass, swap;
char hold[7];
char partid1[7];
char partid2[7];
long recoffset1;
long recoffset2;
long holdrecoffset;
for (pass = 1; pass <= index_c; pass++) {
swap = 0;
for (i = 0; i < index_c - pass; i++) {
strcpy(partid1, indxfrec_t[i].partid);
strcpy(partid2, indxfrec_t[i + 1].partid);
recoffset1 = indxfrec_t[i].recoffset;
recoffset2 = indxfrec_t[i + 1].recoffset;
if (partid1 > partid2) {
swap = 1;
strcpy(hold, indxfrec_t[i].partid);
strcpy(indxfrec_t[i].partid, indxfrec_t[i + 1].partid);
strcpy(indxfrec_t[i + 1].partid, hold);
holdrecoffset = recoffset1;
indxfrec_t[i].recoffset = indxfrec_t[i + 1].recoffset;
indxfrec_t[i + 1].recoffset = holdrecoffset;
}
}
if (!swap)
break;
}
for (i = 0; i < index_c; i++)
printf("\n%s\t%ld", indxfrec_t[i].partid, indxfrec_t[i].recoffset);
}
Help...