|
|
Slime <fak### [at] emailaddress> wrote:
> atoi( mystring.c_str() )
> to convert to an integer. This is what I always use, though I see there are
> other ways to do it.
The problem is that with atoi() you can't know if there was an integer
in that string in the first place. If there wasn't, it just returns zero,
and you can't know if there was a zero in the string or something which
was not a parseable number.
(And no, it's not enough to check if mystring[0] == '0'. There are a
multitude of other ways for a valid number 0 to be in the string.)
This might be very relevant if you are checking if there was a number
of something else in the string, and act accordingly.
--
- Warp
Post a reply to this message
|
|