Originally posted by Twiggy
I've always wondered this. Still learning C myself. What exactly does this do?

Code:
const char* GetDigit(char DigitCharacter)
{
   return DigitString[DigitCharacter - 48];
}
A breakdown of each line would be mondo helpful. Especially the -48
As per the post above mine, if you're going to do this, you really should do:

return foo[ bar - '0' ];

This attempts to avoid the issue described in the previous post. Numbers are, I believe, supposed to be represented sequentially from zero to nine in the character set, which is why this works. I don't recall if this is guarinteed or not.

Anyway, it's generally a good idea to avoid random constants such as that, so that people when they read your code actually know why there is some odd number in your code. Thus, you could do something like what I've illustrated, or you could macro it.
Code:
#define ZERO '0'

return foo[ bar - ZERO ];
Or whatever...

Quzah.