On 2008-05-05 18:21:52 -0400, brad <byte8bits@[EMAIL PROTECTED]
> said:
>
> Wow. That works. I do not fully understand why it works, but I wanted
> to thank you for the advice. I'll research it more until I better
> understand.
>
'0' is a character. It happens to also be a number, but it's the number
that represents the character '0' in whatever encoding the compiler
uses (typically ASCII). But C and C++ both have a rule that the
representations of the characters '0' through '9' must be contiguous
and increasing, that is, '1' is one more than '0', etc. So to convert a
character that represents a digit into the value of that digit, just
subtract '0'.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)


|