Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!news.glorb.com!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: Sat, 11 Feb 2012 18:15:25 -0600 Message-ID: <4F37049C.2FEC@mindspring.com> Date: Sat, 11 Feb 2012 19:15:24 -0500 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: return -1 using size_t??? References: <8c1eef8c-2ba4-441e-aa86-36486b56a261@n12g2000yqb.googlegroups.com> <65729073-738d-4faf-9cbd-20e020532949@p7g2000yqk.googlegroups.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 25 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.156.228.180 X-Trace: sv3-OqK8iUTyD38Lv+Z4sc96wFOP1eGX/c2tJtojssCmetOxONyfF/73RgfWk+QUEQoekRRaHsXmpnqzrJE!20IYZ31gLYXDqnlm7sIYvjug286kFApr4WbJPXO1CvGZgovVCb90sx0ZMNwAgF+l9OGIv3cQYOnH!q/d1Y9mBwaI= 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: 1967 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:17159 Robert Hayes wrote: > > On Feb 11, 2:07 pm, Eric Sosman wrote: > > On 2/11/2012 2:21 PM, Robert wrote: > > > I have read that size_t can hold an unsigned int. > > > I have been playing > > > with using size_t as a return value and I am not sure I should. > Thank you for the clear explanation. I will not use a size_t to hold > a negative number. I *would* use ((size_t)-1) as a return value to indicate an extraordinary condition, *if* there was no possibility that that value might be returned otherwise. The index of the last element of an array with ((size_t)-1) elements, is ((size_t)-2). So, if a function was supposed to return the index number of an array element, a return value of ((size_t)-1) could be used to indicate a problem. -- pete