Use ftell to find the file size
问题 fseek(f, 0, SEEK_END); size = ftell(f); If ftell(f) tells us the current file position, the size here should be the offset from the end of the file to the beginning. Why is the size not ftell(f)+1? Should not ftell(f) only give us the position of the end of the file? 回答1: File positions are like the cursor in a text entry widget: they are in between the bytes of the file. This is maybe easiest to understand if I draw a picture: This is a hypothetical file. It contains four characters: a , b ,