Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #14552
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!nx02.iad01.newshosting.com!newshosting.com!post02.iad!not-for-mail |
|---|---|
| X-Newsreader | xrn 9.03-beta-14-64bit |
| Sender | scott@lews (Scott Lurndal) |
| From | scott@slp53.sl.home (Scott Lurndal) |
| Reply-To | slp53@pacbell.net |
| Subject | Re: Testing for Numeric Digits |
| Newsgroups | comp.lang.c++ |
| References | <MPG.29b45a9820e6ae9a9896f9@news.eternal-september.org> |
| Organization | |
| Keywords | |
| Organization | UseNetServer - www.usenetserver.com |
| X-Complaints-To | abuse@usenetserver.com |
| Message-ID | <NZO2r.76005$o65.73941@news.usenetserver.com> (permalink) |
| Date | 27 Feb 2012 17:22:53 GMT |
| Lines | 23 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:14552 |
Show key headers only | View raw
mrc2323@cox.net (Mike Copeland) writes:
> Is there a relatively easy and simple way to determine if a
>basic::string value is comprised only of numeric digits? I have an
>application that parses a comma-delimited string, and I want to test if
>specific values are strictly numeric. It was working until I got a
>mixed alphanumeric value that started with a numeric digit (e.g.
>"6btt123"), which caused the following code to fail:
>
> int ii = atoi(wStr.c_str());
Use strtol or strtoul.
char *cp;
ulong_t line = strtoul(argv[2], &cp, 0);
if ((cp == argv[2]) // String (argv[2]) didn't start with digit or is empty
|| (*cp != '\0') // String had non-digit before end of string
|| (line >= MAX_DCDLP_LINES)) { // Converted value is illegel
lp->log("%s Illegal line number '%s' specified\n",
t_dlp_name, argv[2]);
return true;
}
s
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Testing for Numeric Digits mrc2323@cox.net (Mike Copeland) - 2012-02-26 15:05 -0700
Re: Testing for Numeric Digits Ian Collins <ian-news@hotmail.com> - 2012-02-27 11:11 +1300
Re: Testing for Numeric Digits Ian Collins <ian-news@hotmail.com> - 2012-02-27 11:22 +1300
Re: Testing for Numeric Digits Paul <pchristor@yahoo.co.uk> - 2012-02-26 16:45 -0800
Re: Testing for Numeric Digits "MikeWhy" <boat042-nospam@yahoo.com> - 2012-02-28 03:17 -0600
Re: Testing for Numeric Digits Paul <pchristor@yahoo.co.uk> - 2012-02-28 03:30 -0800
Re: Testing for Numeric Digits Marc <marc.glisse@gmail.com> - 2012-02-28 15:19 +0000
Re: Testing for Numeric Digits "MikeWhy" <boat042-nospam@yahoo.com> - 2012-02-28 11:04 -0600
Re: Testing for Numeric Digits Andy Champ <no.way@nospam.invalid> - 2012-02-28 20:44 +0000
Re: Testing for Numeric Digits Miles Bader <miles@gnu.org> - 2012-02-27 10:23 +0900
Re: Testing for Numeric Digits scott@slp53.sl.home (Scott Lurndal) - 2012-02-27 17:22 +0000
Re: Testing for Numeric Digits Dombo <dombo@disposable.invalid> - 2012-02-27 20:29 +0100
Re: Testing for Numeric Digits Quint Rankid <qbr567@gmail.com> - 2012-02-28 11:43 -0800
csiph-web