Thanks for the reply MarkT!
So you mean I have to call a seperate function that converts whatever 'char' from 0-F to its HEX equivalent? right?
hahaha Why didn't i think of that! thanks!
No you don't have to, but its much easier to read well-structured code.
But still I have a few questions...
what does res =0L; means? what is 0L?
long integer constants should have an 'L' at the end to tell the compiler you mean a long constant,
often it doesn't matter, but its a good habit to get into if you don't want to be surprised later on.
also what does this mean..
if (c >= '0' && c <= '9')
return c - '0' ;
if (c >= 'A' && c << 'F')
return c - 'A' + 10 ;
if (c >= 'a' && c << 'f')
return c - 'f' + 10 ;
why does it test if the newly declared char c >= '0'?
isn't it that since c is a char it cannot be compared by greater or equal to? (Correct me if 'm wrong...I'm kinda new to this)
so basically what im asking is what does the condition if (c >= '0' && c <= '9') test?
chars are just a kind of integer, namely 8 bit signed integer. The character coding is ASCII (for the first 128 codes at least),
so you can rely on 0..9, A..F and a..f being contiguous code ranges.
also what does return c - 'f' + 10 ; means? what value does it actually returns?
subtract the code for 'f' from the char c, then add ten. I got that wrong BTW, it should be 'a', not 'f'.
Thank you again and sorry for my ignorance...