更新时间:2022-10-15 15:58:35
I believe this is an issue with the way the Windows deals with text files opened with fopen()
. If you take a look at the MSDN page for fopen()
, it indicates that if you open a file with just "r"
as the mode string, some translations will happen with regards to line-endings. This means that the size of the file you query may not match the amount of data read by fread()
.
To solve this, simply change the mode string to indicate that you wish to read the file as binary data (i.e. without any pesky translations):
FILE* file = fopen(files[i], "rb");