Re: _ttoi function - checking return value
- From: "Bruce Eitman [eMVP]" <beitman.nospam@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 11 Jan 2008 09:49:44 -0500
I think that you need to validate the user input, not your interpretation of
the input which you are showing can and will change the value if the user
input is out of range.
--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net
Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member
<ToeKneeSee@xxxxxxxxxxxxxx> wrote in message
news:2024c007-be4a-48c0-8548-ad6ae61fe3a7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
I'm using the "_ttoi" function to convert a user-input string into an
integer, and want to check that the user-entered value is within an
integer's range, by checking against INT_MIN and INT_MAX.
However, overflows can occur, so that for example 9999999999 results
in 1410065407 being returned by the _totoi function, which would
erroneously pass the " if( x >= INT_MIN && x <= INT_MAX ) " test.
Does anyone have any ideas how best to validate user-input such as
this?
Thanks for any help,
Tony.
.
- Follow-Ups:
- Re: _ttoi function - checking return value
- From: ToeKneeSee
- Re: _ttoi function - checking return value
- References:
- _ttoi function - checking return value
- From: ToeKneeSee
- _ttoi function - checking return value
- Prev by Date: _ttoi function - checking return value
- Next by Date: Re: _ttoi function - checking return value
- Previous by thread: _ttoi function - checking return value
- Next by thread: Re: _ttoi function - checking return value
- Index(es):
Relevant Pages
|