I am new to the endians. I am trying to convert a big endian integer array to hexadecimal string in little endian. I tried to convert big endian integer array to little endian hexa decimal string. But at the end, getting big endian hexa decimal encoded string instead of little endian. Please help me
gint16 frame[5] = {10, -26, 35, 7, -35}; //big endian
gint16 frame_i[5];
size_t i;
for (i= 0; i < 5; i++) {
frame_i[i] = (frame[i] << 8) | ((frame[i] >> 8) & 0xFF); //big endian to little endian
}
char *str = malloc(5 * 4 + 1);
size_t j;
for (j= 0; j < 5; j++) {
snprintf(str + j * 4, 5, "%04X", frame_i[j] & 0xFFFF); // getting big endian instead of little endian
}