problems with fread() always returning 1
问题 I have looked at similar questions, but mine is a bit different. I make sure to open file in binary mode and to check if error occurs while reading. File contents: message1, message2, 53467 program to read simple file: int bytesRead; FILE* CSV; CSV = fopen("\\Temp\\csv.txt", "rb"); char dataBuf[128]; while ( (bytesRead = fread(dataBuf, 1, sizeof(dataBuf), CSV) > 0) ) { if (ferror(CSV)) //handle error //do stuff with dataBuf contents } fread() is always returning 1. ferror is also not entered,