// This is just a simple converter that takes a binary string and converts it to a char array
#include <string.h>
#include <math.h>
int i = 0;
int length = strlen(BINARYINPUT) / 8; // I have no clue how your original data is saved.
unsigned char output[length];
unsigned char out = 0x00; // It looks trashy to me if a loop declares a value every iteration
do {
out = bin2dec(BINARYINPUT.substr(i*8,i*8+8)); // 8 chars per hex value, so pos of the substring is i*8, length is i*8+8
output[i] = out;
i++;
} while (i < length);