#include <myhead.h>
int main(int argc, const char *argv[])
{
int fd1=open("./1.txt",O_RDWR|O_CREAT|O_TRUNC,0664);
if(fd1==-1)
{
perror("no");
return -1;
}
int fd2=open("./2.txt",O_RDWR|O_CREAT|O_TRUNC,0664);
if(fd2==-1)
{
perror("no");
return -1;
}
char buf[100]="hello world";
int len=write(fd1,buf,sizeof(buf));
close(fd1);
fd1=open("./1.txt",O_RDONLY);
char ave[100];
read(fd1,ave,len);
printf("%s",ave);
write(fd2,ave,len);
return 0;
}
使用write和read完成文件的拷贝。
最新推荐文章于 2024-08-27 18:51:28 发布