How to apply numeric value to char variable?

1
2
3
4
5
6
7
8
9
int a = 10, b = 11, c = 12, d = 13, e = 14, f = 15;
int n = 0;
int num;
string h;
cout << "Enter a number:\n";
cin >> h
for(int i = h.length(); i > 0; i--){
    num = num + (h[i-1] * pow(16, (h.length()-1-i)));
}

I'm trying to do a string to hexadecimal conversion. When the user inputs "aa", the output integer should be 176, but I have no idea how to get 'a' to equal 10 while in the loop.
Last edited on
But how do I use that for char? h[] returns a char not a string
Topic archived. No new replies allowed.