Not sure it has to be that confusing, I was able to run your code with the following minor corrections:
Code:
//int nxt_char, cmdopt, cmdport, nibble0, nibble1;//, index;
const char hex_str[] = "0123456789ABCDEF";
int hex_value = 0;
You don't use anything on the first line anyway, and the only other thing is that the hexstr_ptr has to point to an UPPERCASE hex value.
I printed my output like this:
Code:
#include <iomanip>
std::cout<< std::hex << foo("DEADBEEF") << std::endl;
foo is your function.