Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Function-types: compatability, and typedefs Message-ID: <19367@mimsy.UUCP> Date: 1 Sep 89 14:12:45 GMT References: <19361@mimsy.UUCP> <1996@munnari.oz.au> Distribution: comp Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 26 >In article <19361@mimsy.UUCP> I wrote: >>... the answers FOR THIS PARTICULAR CASE are `yes' and `yes'. >> int (*)(void *, void *) [qsort compare function] >> and int (*)(char *, char *) [strcmp] In article <1996@munnari.oz.au> ok@cs.mu.oz.au (Richard O'Keefe) writes: >If you want to sort an array of strings ... **don't** try to pass >'strcmp' as the fourth argument of qsort(). ... What you need is > int strptrcmp(char **s1, char **s2) > { return strcmp(*s1, *s2); } Oops, quite right. I got tied up in the `do the two function types match' question and never noticed the fact that qsort is passing pointers to the objects (here pointers to char *), rather than to that to which the objects point. >Did you know that C.A.R.Hoare pointed out in 1962 that Quicksort does >1.4 times as many comparisons as [the number done by merge sort]? >He should know: he invented it. Yes, but everyone likes to analyse Quicksort. :-) That is, I think the reason it is used so often is, well, because it is used so often. (Familiarity breeds distemper, or something like that :-/ ) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris