Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 23 Jul 2012 22:34:11 -0500 Message-ID: <500E17B1.2144@mindspring.com> Date: Mon, 23 Jul 2012 23:34:09 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: qsort man page References: <89644623-7e1c-4f8b-9f4d-6443526f0f73@u2g2000yqj.googlegroups.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 33 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.156.228.78 X-Trace: sv3-AkbBNkAGZnVVUcHTZMd7+sx9pvXJUGeoNCuUKb1hvkVOGWf67Gk3Zk2OW8TGkLIJReSqTriDwFYp//+!VHrgDr0BQ/qFM7z/AC2ndomP4BygXRl0SGZRZXqTNIJByL44LMOBFhRFfqPA+k5bFEmbBcvCu2Ry!b6N2qC2Cng== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2087 Xref: csiph.com comp.lang.c:23644 Bill Cunningham wrote: > > This is from the qsort man page. I don't quite understand why there is > a comment here saying that arguments to this generic function to pass > to qsort is a pointer to pointer. > It looks to me like cmpstringp takes > a generic pointer. Not pointer to pointer. Why does the comment say > pointer to pointer? Because the argument that qsort will pass to cmpstringp, when qsort calls cmpstringp, is a pointer to a pointer. > This is confusing me also with the strcmp > parameters which are cast as a pointer to pointer and dereferenced. The argument that qsort will pass to cmpstringp, when qsort calls cmpstringp, is a pointer to a pointer. > static int > cmpstringp(const void *p1, const void *p2) > { > /* The actual arguments to this function are "pointers to > pointers to char", but strcmp(3) arguments are "pointers > to char", hence the following cast plus dereference */ > return strcmp(* (char * const *) p1, * (char * const *) p2); > } -- pete