Originally Posted by
Hunter2
>>So when the user types "a" the program would see "a" and then display 1.
Wouldn't work. The closest you'll get to this is:
OR, you could reverse what I already gave you:
Code:
#include<iostream>
using namespace std;
int main()
{
cout<<static_cast<int>('A')-64<<','<<static_cast<int>('a')-96;
//you could also put the subtraction inside:
//cout<<static_cast<int>('A'-64)<<','<<static_cast<int>('a'-96);
cin.get();
return 0;
}
the only thing with that is if you want 'A' and 'a' to have the same numeric value, you'll need to test to see if it's a capital letter first and then use the correct number to subtract from it...
same thing the other way... if you want 'A' and 'a' both to be the same, you'll need to change the case internally and then cast it to an int...