> > > > Couple points on functions:
> > > > * atoi() takes a const char *, not an individual character. You
> > > > use it here.
> > > > * isdigit() actually takes an integer as a param. So you could use
> > > > int *or* a char as the argument (a char would be cast implicitly).
> > > > not sure if cin allows ints to be read in as chars (I guess not),
> > > > you could do something like this:
> > > > int x;
> > > > char a;
> > > > cin >> a;
> > > > if (isdigit(a))
> > > > x = a - '0'; // it's a trick, but it's portable and it works.
> > > only portable between environments in which the character set encodes
> > > numeric characters sequencially, and in the right direction.
> > That includes every environment with a compliant
> > implementation of the language.
> Where is it dictated that (for example) ('0' + 5 == '5') ?
From ISO/IEC 9899 (The ISO C standard) 5.2.1
[ list of reequired characer set members ]
"In both the source and execution basic character sets, the
value of each character after 0 in the above list of decimal digits shall be
one greater than
the value of the previous."
I didn't see a specific statement like this one in ISO/IEC 14882
(C++ standard), but I'm pretty sure it uses the above C definition
> Clark S. Cox, III