1、写文件write函数:
#include <stdio.h>
//文件操作函数头文件
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
ssize_t write(int fd, const void *buf, size_t count);
–参数fd表示:使用open 函数打开文件之后返回的句柄
–参数*buf表示:写入的数据
–参数count表示:最多写入字节数–返回值:出错-1,;其它数值表示实际写入的字节数
2、读文件read函数:
//标准输入输出头文件
#include <stdio.h>
//文件操作函数头文件
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define MAX_SIZE 1000
ssize_t read(int fd,void *buf,size_t len);
–参数fd:使用open 函数打开文件之后返回的句柄
–参数*buf:读出的数据保存的位置
–参数len:每次最多读len 个字节
–返回值:错误返回-1,执行成功返回实际读取值