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?

also what does return c - 'f' + 10 ; means? what value does it actually returns?

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.

Quote

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.

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.

Quote

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'.

Can anyone give me a sample code for the conversion of char to Hex value?.for example I have achar result[7]=( A, B, C, D, 1, 2, 3);(snip)because later I want to convert it to something like thisresult= 0xABCD123;

If your array is populated with ASCII characters then you could just make sure it was null-terminated and parse it directly to an integer using strtol() or strtoul().

I only provide help via the forum - please do not contact me for private consultancy.