File contains:
AAA+BCDEF (converting to hexadecimal first)
But the issue I have is with the actual addition function. I get 0 output from the console, not even 0. I'm not sure how to read the file "AAA+BCDEF". Thought the ifstream would pass it but now I'm just confused. Help?
Code
void addHex(ifstream inFile)
{
char ch;
long int num1 = 0;
long int num2 = 0;
inFile << ToHexdecimal(num1) << ToHexdecimal(num2);
ToHexdecimal(num1) + ToHexdecimal(num2);
}
string ToHexdecimal(long int decimalNum)
{
long int result;
int tempVal;
stack <char> hexDecimal;
string hexString;
stringstream concat;
result = decimalNum;
while (result != 0)
{
tempVal = result % 16;
if (tempVal < 10)
{
tempVal += 48;
}
else
{
tempVal += 55;
}
hexDecimal.push(tempVal);
result /= 16;
}
while (!hexDecimal.empty())
{
concat << hexDecimal.top();
hexString = concat.str();
hexDecimal.pop();
}
return hexString;
}