关于系统调用的open的应用举例

来源:互联网 发布:进化算法和遗传算法 编辑:程序博客网 时间:2024/04/27 02:14
 #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>




#include <unistd.h>
#include<stdio.h>
#include <string.h>
#define  SIZE 1024


int main()
{
int fd =open ("abc",O_RDWR|O_CREAT,0777);
if (fd==-1)
{
perror("open fd");
return -1;
}

lseek(fd ,20,SEEK_SET);
char *buf="hello";

write (fd,buf ,strlen(buf));


close (fd);

return 0;


}
原创粉丝点击