I\'m trying to write a code that would convert letters into numbers. For example A ==> 0 B ==> 1 C ==> 2 and so on. Im thinking of writing 26 if statements. I\'m wondering
Since the char data type is treated similar to an int data type in C and C++, you could go with some thing like:
char c = 'A'; // just some character int urValue = c - 65;
If you are worried about case senstivity:
#include // if using C++ #include int urValue = toupper(c) - 65;