#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main()
{
int fd;
char *buf = "longhaiyang heng ai sasa";
fd = open("./file1",O_RDWR);
int dd;
if(fd == -1){
printf("open faild\n");
fd = open("./file1",O_RDWR|O_CREAT,0600);
if(fd > 0){
printf("creat fial1 successful\n");
}
}
dd = write(fd,buf,strlen(buf));
printf("%d\n",dd);
close(fd);
return 0;
}```

被折叠的 条评论
为什么被折叠?



