参考: http://blog.csdn.net/dreamtdp/article/details/7560654
1. fopen, fread, fwrite是ANSI C的标准库,open, read, write是UNIX下的系统调用(WINDOWS下分别为_open, _read, _write);
2. fread, fwrite带缓冲功能,底层也是通过read,write实现的;
例如: 如果文件大小是8k。 如果用read/write,且只分配了2k的缓存,则将此文件读出/写入需要做4次系统调用来实际操作磁盘读写;
如果用fread/fwrite,系统自动非配缓存,则读出/写入此文件只需要一次系统调用,效率比read/write要高4倍。
3. 由于f族函数是标准库的内容,因此更具移植性;
4. 测试代码:
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
#include <fcntl.h>
#include <io.h>
const in