I want to read the first 4 bytes from a binary file, which is a type of song.wav. In the .wav file, the first 4 bytes should be 52-46-49-49, and I should read them later if they are correct.
The thing is, I have a compiler in the fread line that says invalid conversion from "unsigned char" to "void" and initialzing argument 1 of 'size_t fread(void*,size_t,size_t,FILE*) , and I don't know what that means.
In the previous section, I saw how this is done if you need to read byte by byte. If anyone knows how I can read bytes by bytes and store them in an array that will be large. Thanks.
void checksong(char *argv[]){ FILE *myfile; int i; unsigned char k[4]; myfile=fopen(argv[2],"r"); i=0; for(i=0; i<4; i++){ fread(k[i],1,1,myfile); } for(i=0; i<4; i++){ printf("%c\n", k[i]); } return ; }
source share