From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,6e2fef38c9bfb3bf X-Google-Attributes: gidf7344,public X-Google-Thread: 1164f8,6e2fef38c9bfb3bf X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1995-02-06 15:14:06 PST Path: nntp.gmd.de!newsserver.jvnc.net!howland.reston.ans.net!math.ohio-state.edu!caen!crl.dec.com!crl.dec.com!pa.dec.com!nntpd2.cxo.dec.com!nabeth.cxo.dec.com!alan From: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) Newsgroups: comp.sys.dec,comp.os.vms Subject: Re: Qsort problem in DEC C Date: 6 Feb 1995 23:14:06 GMT Organization: Digital Equipment Corporation Distribution: world Message-ID: <3h6afu$fsn@nntpd2.cxo.dec.com> References: Reply-To: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) NNTP-Posting-Host: nabeth.cxo.dec.com Xref: nntp.gmd.de comp.sys.dec:21511 comp.os.vms:64077 In article , lloyd-dr@nlvvax.llnl.egg.nv.doe.gov (David Lloyd) writes: > [ A common qsort compare routine problem. ] > >int compare (int *a, int *b) >{ > if (a < b) return(-1); > if (a == b) return(0); > if (a > b) return(1); >} > Ignoreing the strange message about the arguments, they really are pointers being passed. Your code is comparing the value of the pointers, not the integers they to which they point. Useful code would look like: if( *a < *b ) return -1 ; else if( *a == *b ) return 0 ; else return 1 ; -- Alan Rollow alan@nabeth.cxo.dec.com