I made a new Win32 console project with the following code. The program exits with exit code 5. It fails to read from the file just before fclose. I am facing the problem in another code. Here i have recreated the problem. Any idea what i could be doing wrong??
I dont know why above shoudl fail, but I want to recommand a correct use of fread and fwrite,
You need to supply size of single element in second argument (which in your case of sizeof(char)) and count = number of items (4 items in your case). I have seen problem with reading becase of this type of misuse. I guess fread/fwrite simply does not multiply the count*size to read bytes.