Problem
Quite a common task in programming is the need to find the ASCII value of a character. The code below demonstrates how to do this in D.
Solution
int main(char[][] args) {
auto ch = 'A'; int charAsInt = ch; printf( "%d", charAsInt );
return 0;}
In D, getting the ASCII value of a character a trivial task. Simply assign the character to an integer and D will “promote” the character to reveal its ASCII value.
Some other points to note about the above code are:
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.