The following fucntion could achieve the goal:
#include <stdio.h>
static const char __hexa__[16] = {'0', '1', '2', '3', '4' , '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
void fprintBuffer_raw(FILE* file, const char* buffer, size_t buffer_length){
size_t i;
for (i = 0; i < buffer_length; i ++){
fprintf(file, "%c%c", __hexa__[(buffer[i] >> 4) & 0x0f], __hexa__[buffer[i] & 0x0f]);
}
}