1:对文件的常见操作函数
1.1 系统函数
打开文件:open()
向文件中写:write();
从文件中读:read();
1.2 C库函数
打开文件:fopen()
向文件中写:fwrite();
从文件中读:fread();
2:对目标文件进行操作
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <wchar.h>
#include <locale.h>
#define BUFSIZE 1024
int main(int argc,char *argv[])
{
wchar_t buf[BUFSIZE]={0};
FILE *fd=fopen("filename","r+");
if(NULL==fd)
{
perror("fopen faile");
return 0;
}
while(fgetws(buf,BUFSIZE,fd)!=NULL)
{
wprintf(L"%ls\n",buf);
}
return 0;
}