I have read in a binary file to an array of chars (DATA). So far so good however I cannot convert it to "human readable format" since it seems to be in hexadecimal format. I know that the file has a 512 byte long header and in matlab float32 is the type in the fread function. The rest of the file is the data in double or float (hopefully).
When I try to print it out then the std::cout << DATA[i] << "\n" does not print anything. I can access the hexa format easily with a c-type printf("%X ", DATA[i]) funtion. However this gives an error: printf("%s ", DATA[i])
Is there a way in C++ to convert the hexadecimal information to "human readable format" (ASCII)?
How can I print the hexadecimal info with cout?
Why do I get different entries if I use unsigned char rather then char for the DATA type?
It seems you are assuming there is a one-to-one correspondence with the data in the binary file and the ASCII conversion. Maybe it's not that simple with the binary file and the data is altered in som way and otherwise surrounded by other non-data information. It might be executable code?
The file is definitely not an executable. It is a data file for sure. It contains a whole loads of floats. However how many of these floats are stored is coded in the header part of the binary. The final goal would be to write my own function of course but before that I would like to understand the nitty-gritty details. I think where I went wrong so far is what Necip points out that I need actually 4 bytes for the float. However I thought it is possible to print it as an ascii human readable file and then see what is what. Well, I was wrong there. :)