In the old days, when we could assume that most computers used ASCII, we would just do
int i = c[0] - '0';
But these days Unicode is not a good idea. It has never been a good idea if your code should run on a non-ASCII computer.
Edit: Although this looks like a hacker, it is obvious that the standard is working. Thanks @Earwicker.
Paul Tomblin May 15 '09 at 12:52 2009-05-15 12:52
source share