Compiling on linux using gcc.
I would like to convert this to hex. 10, which would be a. I managed to do this will be the code below.
unsigned int index = 10; char index_buff[5] = {0}; sprintf(index_buff, "0x%x", index); data_t.un32Index = port_buff;
However, the problem is that I need to assign it to the structure and the element I need to assign is the unsigned int type.
However, this works:
data_t.un32index = 0xa;
However, my sample code does not work, as it thinks I'm trying to convert from string to unsigned int.
I tried this, but it also failed
data_t.un32index = (unsigned int) *index_buff;
Thanks so much for any advice,
source share