1 /*************************************************************************
2 > File Name: MyOpen.cpp
3 > Author: xuchen_allen
4 > Mail: xuchen_allen@163.com
5 > Created Time: 2019年01月29日 星期二 10时11分33秒
6 ************************************************************************/
7
8 #include<iostream>
9 using namespace std;
10 #include<sys/types.h>
11 #include<sys/stat.h>
12 #include<fcntl.h>
13 #include<unistd.h>
14
15 int main()
16 {
17 //打开一个已经存在的文件
18 int fd = open("english.txt",O_RDWR);
19 if(fd == -1){
20 perror("open file:");
21 exit(1);
22 }
23
24 //创建一个新文件,在其中写入读取的内容:
25 int fd_1=open("newfile",O_CREAT | O_WRONLY,0664);
26 if(fd_1 == -1){
27 perror("write:");
28 exit(1);
29 }
30
31 //读取文件内容&#x