I am trying to read binary files and storing the content into a char array. This function is working great for text files, but for non-text files (a PNG file for example) it doe
The strlen
function is exclusively for use on C-style strings. There is no way to tell the length of arbitrary binary data by looking at its content. You have the length in lengthRead
.
fprintf(stderr, "Content read:\r\n%s\r\n", *contents);
Same problem here. The %s
format specifier is for C-style strings, not arbitrary binary data. You'll need to write your own function to print the data in some appropriate format.