C fread not getting entire file
问题 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 does not work as expected. Below is the code followed by the results. What is wrong? Code: #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> unsigned int readFile(const char *fileName, char **contents); int main(int argc, char *argv[]) { char *contents = 0; unsigned int length = readFile(argv