I'm trying to use a C++ program to convert a hexadecimal value into a decimal value. Just can't come up with a working code.
This is the best thing I have come up with:
int main () {
    string link;
    string hex_code;
    int dec_code;
    int i;
    int n = 6;
    int num;
    int hex;
    cout << "Insert 1 of the HEX characters at a time:";
    for (i = 0; i < n; i++) {
        cin >> hex_code;
    }
    for (i = 0; i < n; i++) {
        if (hex_code == "A") {
            hex_code = 10;
        }
        else if (hex_code == "B") {
            hex_code = 11;
        }
        else if (hex_code == "C") {
            hex_code = 12;
        }
        else if (hex_code == "D") {
            hex_code = 13;
        }
        else if (hex_code == "E") {
            hex_code = 14;
        }
        else if (hex_code == "F") {
            hex_code = 15;
        }
        else {
            hex_code = hex_code;
        }
        num = hex * pow (16, i);
    }
    for (i = 0; i < n; i++) {
        dec_code = dec_code + num;
    }
    cout << dec_code;
return 0;
}
Any help/feddback/opinions are welcome.
Edit: Thank you for all your help. Found the code I tryed to create, but failed, here: https://stackoverflow.com/a/27334556/13615474
 
     
     
    