I am trying to read a file which contains bytes into a hex string.
std::ifstream infile("data.txt", std::ios_base::binary);
int length = 10;
char char_arr[length];
for (int i=0; i<length; i++)
{
infile.get(char_arr[i]);
}
std::string hex_data(char_arr);
However the hex_data
does not look like a hex string. Is there a way to convert the bytes to a hex string during reading?