Hello everyone
I have a buffer which contains ascii characters(representing 4 bytes eg AB0400) which I want to convert first two numbers back into hex(0400).I can retrieve hex numbers only if they dont contain numbers.The code below shows this process.
Code:
uint8_t buffer[32];
receive_buffer(buffer,sizeof(buffer));//now buffer contains ascii characters(eg: AB0400)
func(((buffer[2]-0x30)<<8)+(buffer[3]-0x30));//retrieves first two ascii characters,converts it into hex and sticks it into the function.
As seen from above, the code works only for numbers,however, say i had a buffer which contains (AB0A00)what to do then. Therefore I need a more generic routine which can tackle any ascii character.There are lot of notes on the internet ,that confuses me ,So I am looking for something that would suite my requirements.Thank you