Well I have been trying to convert this integer into hex and have successfully done so but I need to use this hex for setting something. Now for this I need to use a char not a char array. Nothing else has worked without manually setting it. Maybe the problem lies in the issue that I use sprintf for the conversion to hex but either way I am sure there is a way to complete this task. Now What I need to change is have the output be char z but I haven't found a way to get this to work. Any help is greatly appreciated. Thanks
EDIT: now thi code may not make sense directly because it is incomplete and I saw no purpose inputting unrelated code. int x will never be over 100 and the whole point is to convert this into a hex and write it to the memory of a setting I have. So I have been trying to figure out how to convert the integer into hex into a char. nonstring as someone pointed out even though sprintf converts it to a string stored in a char as I just noticed. But I need to take the int convert to hex and assign that to a char variable forbuse later on. And that is where I am stuck. I do not know the best way to go about completely all that in a format and way without going into a string and other things.
VOID WriteSetting(int x)
{
char output[8];
sprintf(output, "0x%X", x);
char z = 0x46
unsigned char y = z
}
Working Code:
VOID WriteSetting(int x)
{
unsigned char y = (unsigned char)x;
Settingdb.Subset.Set = y;
}