I want to convert an integer array to an array of characters by formatting the integers in hexadecimal, then I leave an example of how I do it now, however, I would like an easier way to do it with sprintf, this is because when there are many values instead of two the sprintf function would be very long and poorly optimized:
int int_array[2];
char char_array[2];
unsigned char uchar_array1[2];
unsigned char uchar_array2[2];
uchar_array1[0] = 0x31;
uchar_array1[1] = 0x32;
uchar_array2[0] = 0x33;
uchar_array2[1] = 0x34;
int_array[0] = uchar_array1[0] ^ uchar_array2[0]; //Funcion XOR
int_array[1] = uchar_array1[1] ^ uchar_array2[1]; //Funcion XOR
sprintf(char_array, "%02X%02X", int_array[0], int_array[1]); //Función a Mejorar
I tried to do this:
for(int aux = 0; aux < 2; aux++)
{
sprintf(char_array[aux], "%02X", int_array[aux]);
}
But he sends me the following error:
argument of type "char" is incompatible with parameter of type "char *"