converting letters to numbers

closed account (4Gb4jE8b)
I'm working with direct.h (again) and I'm trying to use chdrive(int). It works in windows as drive A = 1, B = 2, C = 3, D = 4 so on so forth. However other than a long series of switch statements, which i really don't want to do, i have no idea how i can make this conversion. Any ideas?
closed account (3hM2Nwbp)
Character - 64 = number

So:
Subtraction
'A' - 64 = 1
'B' - 64 = 2

-or-

Bitwise

'A' & 63 = 1
'B' & 63 = 2

*I'm not sure which one would take fewer ticks - but it's in all aspects negligible.

etc.

*Edit* - Unless I misinterpreted the question?
Last edited on
closed account (4Gb4jE8b)
Oh you're amazing! Thank you very much
You better don't use magic numbers. c-'A'+1
closed account (4Gb4jE8b)
of course, ne555
Topic archived. No new replies allowed.