I need to convert an int to a 2 byte hex value to store in a char array, in C. How can I do this?
Perhaps try something like this:
void IntToHex(int value, char* buffer) { int a = value&16; int b = (value>>4)&16; buffer[0] = (a<10)?'0'+a:'A'-(a-10); buffer[1] = (b<10)?'0'+b:'A'-(b-10); }