fread的问题
num=fread(buffer, sizeof(char),SIZEFILE,pFile);当num 为0的时候表明文件读取结束了吗? 问题点数:20、回复次数:2Top
1 楼coldwindtang(风)回复于 2006-10-01 17:32:21 得分 10
fread返回读取的数据项的个数(不是字节的个数),如果操作出错,fread返回0。
所以,0代表文件结束等一切可能的出错。Top
2 楼Jokar(贪睡鼠)回复于 2006-10-01 18:12:07 得分 10
Return Value
/***fread returns the number of full items actually read, which may be less than count if an error occurs or if the end of the file is encountered before reaching count.***/ Use the feof or ferror function to distinguish a read error from an end-of-file condition. If size or count is 0, fread returns 0 and the buffer contents are unchanged.
Parameters
buffer
Storage location for data
size
Item size in bytes
/***count***/
Maximum number of items to be read
stream
Pointer to FILE structure
以上引自msdn`
Top




