do fread and fwrite have failure? how to handle this?
问题 when I read from a file using fread (C language), the return value of fread sometimes would be 0. As manual suggested: fread() and fwrite() return the number of items successfully read or written do I have to write code like this? int bytes_read; while((bytes_read = fread(buffer, sizeof(int), 1, fp)) == 0) { } do we always have to check whether fread or fwrite succeeded? 回答1: No, there's no sense in doing a retry-loop like this if fread or fwrite returns fewer than the expected number of