Category : C Source Code
Archive   : C-TOOLBX.ZIP
Filename : RESORT.C

 
Output of file : RESORT.C contained in archive : C-TOOLBX.ZIP
/* resort.c - resort after last element of array replaced */
/* uses pointers to actual data elements and compare functions */
#include "stdio.h"

int resort(pa,na,pcomp)
char *pa[] ; /* array of pointers to elements to be sorted */
int na ; /* number of elements to be sorted */
int (*pcomp) () ; /* pointer to compare function */
{
int i , j ; /* indeces for loops */
char *ptemp ; /* temporary storage of one pointer */
/* insert the last element into the sorted array */
i = na - 1 ; /* last element */
ptemp - pa[i] ;
j = j - 1 ;
while( (j >= 0) && (*pcomp)(ptemp,pa[j]) < 0 )
{ pa[j+1] = pa[j] ;
j = j - 1 ;
}
pa[j+1] = ptemp ;
}






  3 Responses to “Category : C Source Code
Archive   : C-TOOLBX.ZIP
Filename : RESORT.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/