🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3801

qsort() help

#3801
From: Keith Ford
Date: Thu, 15 Oct 1992 18:36
45 lines
1801 bytes
I am having trouble implementing my own compare function for the qsort
routine within Borland C.  Below are the code fragments of importance. 
In LOCATE.C, the first call to qsort() compiles and works okay, the
second generates an error.  Any help whould be appreciated.  I am
starting to feel really stupid with this thing.  I have tried a number
of different calling forms, each with equal disappointment.



WINK.H
-----------------------------------------------------------------
# include <stdio.h>
# include <stdlib.h>
# include <alloc.h>
int LocateAreas (void);
static int AreaNumberCompare (void *a, void *b);




LOCATE.C
-----------------------------------------------------------------
#include <wink.h>
int LocateAreas (void)
  {
  areas = (struct paths **) calloc (num_areas, sizeof (struct paths *));
  for (i=0,curr=head; curr; ++i,curr=curr->next)
    areas[i] = curr;
  qsort ((void *)areas, num_areas, sizeof(struct paths *), strcmp);
  qsort ((void *)areas, num_areas, sizeof(struct paths *), AreaNumberCompare);
  }


int AreaNumberCompare (void _FAR *a, void _FAR *b)
  {
  struct paths _FAR **aa;
  struct paths _FAR **bb;
  aa=a; bb=b;
  return ((*aa)->area_number - (*bb)->area_number);
  }
-- 
Keith E. Ford     __
Intergraph Corp  /  \ Micro Magic BBS 1:373/12  The Dragon Server
+1 205 730-8614  \__/ sysop@umagic.fidonet.org  server@ingr.com
fordke@ingr.com  [__] 830-2362 HST/V32bis 9600  "Subject: HELP"
Technical Details
Message-ID: <1992Oct15.183616.21088@infonode.ingr.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!fordke

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!fordke
From: fordke@infonode.ingr.com (Keith Ford)
Subject: qsort() help
Message-ID: <1992Oct15.183616.21088@infonode.ingr.com>
Organization: Intergraph Corporation, Huntsville, AL.
Distribution: usa
Date: Thu, 15 Oct 1992 18:36:16 GMT
Lines: 45