#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main()
{
int fd=0;
char buf[]=“hello world”;
fd =open("./file.txt",O_RDWR);
if(fd==-1)
{
printf(“open fail\n”);
return 0;
}else
{
printf("open ok\n");
}
write(fd,(void *)buf,11);
lseek(fd,SEEK_SET,0);
char buf2[12];
read(fd,buf2,sizeof(buf2));
printf("%s\n",buf2);
return 0;
}