home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!rpi!news.ans.net!cmcl2!adm!claudius!cor5.pica.army.mil!birnbaum
- From: birnbaum@cor5.pica.army.mil (Richard C. Birnbaum (GC-ACCURATE) <birnbaum>)
- Newsgroups: comp.lang.c
- Subject: Re: Help. (Unix C)
- Message-ID: <1992Nov5.154636.10510@pica.army.mil>
- Date: 5 Nov 92 15:46:36 GMT
- References: <1992Nov3.230425.15029@ucsu.Colorado.EDU> <Bx62ux.606@portal.hq.videocart.com> <2214@sdrc.COM>
- Sender: news@pica.army.mil (USENET Special Account <usenet>)
- Organization: U.S. Army Armament Research Dev. & Eng. Ctr, Dover NJ
- Lines: 15
- Nntp-Posting-Host: cor5.pica.army.mil
-
- .. discussion of qsort and comparison function for comparing float members
- of structures deleted....
-
- instead of the comparison function doing
-
- if (ptr->item1 == ptr->item 2) return 0;
- if (ptr->item1 > ptr->item 2) return 1;
- return -1;
-
- you could do simply
-
- return (ptr->item1 - ptr->item2);
-
- You need not return only the values 0, 1, or -1 - you must return 0,
- positive number, or negative number.
-