Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!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: Wed, 01 Aug 2012 10:35:20 -0500 Message-ID: <50194CB7.285A@mindspring.com> Date: Wed, 01 Aug 2012 11:35:19 -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: Restricted unsigned integer range would have been better? References: <5011E247.1F7B@mindspring.com> <5012954D.20C@mindspring.com> <5018AE22.152C@mindspring.com> <0.41a5266becbe1d48f128.20120801125152BST.87r4rq4yp3.fsf@bsb.me.uk> <50191E78.CDB@mindspring.com> <0.837a8fa3b84a81796f37.20120801142215BST.87lihy4uig.fsf@bsb.me.uk> <501935C7.5D52@mindspring.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.221.138 X-Trace: sv3-u47e5XwXoaRii+oENJtYSxoLsmhKTc4VaEsgKvyW5yY3gb2bjRAc8Wu6mx0KTEohEydZgskk8b30t4m!pzeV7JTVJV7fMQEvBx+1q6hsCFG6AYAtntE0xQpS/lfHLkPQjNbs6ho7suXoePVwiiMvmqQ0TF8P!owfxMrdvPYA= 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: 2463 Xref: csiph.com comp.lang.c:24063 pete wrote: > I also think I should change the condition my loop from > while (isdigit(*nptr)) { > to > while (*nptr != '\0') { > similar to what Philip Lantz had. > I think that the spirit of atoi > is that it is supposed to be a simple function, > which is only to be used > when it is known that the input won't cause any problems. However, my intention was that the function which I wrote, should do what the standard says that atoi does. atoi is described in terms of what strtol does. And since strtol is described as decomposing the string into three parts, (the middle one being called "the subject sequence") and only operating on the subject sequence, I think that while (isdigit(*nptr)) { is the way for the code that I wrote, to do what I want. -- pete