Path: csiph.com!x330-a1.tempe.blueboxinc.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: Sun, 15 May 2011 18:45:48 -0500 Message-ID: <4DD065AF.184F@mindspring.com> Date: Sun, 15 May 2011 19:45:51 -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: I need help References: <04ee4fd1-29ef-4640-a906-22055187c1e4@glegroupsg2000goo.googlegroups.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 27 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.217.250 X-Trace: sv3-njrOBtWWO4PjsmWSDW9Vr/elFahtf4WlWoWMrg9nnBR0eNlMnhymcs52rxAM14ILBkDdmSbX2BxWEvI!pjI3YlZfWtKCF7fA/IVD58ExiQ+eJ9ylqC378vDYsjTMNhsmbIiISAfgvzV/hwpRIhFZmtd1gOyc!7nUkUpxWqZ0= 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: 2009 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:4039 Eric Sosman wrote: > > On 5/15/2011 5:37 PM, sandeep wrote: > > Eric Sosman writes: > >> char *space = strchr(karmarkar, ' '); if (space == NULL) > >> printf ("No spaces\n"); > >> else > >> printf ("First space is at position %u\n", > >> (unsigned)(space - karmarkar)); > > > > This could give the wrong answer on implementations > > where PTRDIFF_MAX > UINT_MAX. > > Thank you so very, very much for this helpful observation, > guaranteed to clarify matters for the O.P. sandeep is wrong. The context (snipped by sandeep) for which your code was written, is this: char* karmarkar = "Karmarkar 958572"; And in that context, there is no way that the difference between (space) and (karmarkar) can excede either UINT_MAX or PTRDIFF_MAX (which would be a different C trivia point). -- pete