#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include<errno.h>
#include <unistd.h>
#define SIZE 1024
int main ()
{
int fd1=open ("1.ppt",O_RDONLY);
if (fd1==-1)
{
perror("open fd1");
}
int fd2=open("2.ppt",O_WRONLY|O_CREAT,0777);
if (fd1==-1)
{
perror("open fd2");
}
int ret=0;
char buf [SIZE]={0};
while (ret=read(fd1,buf,SIZE))
{
if (ret ==-1)
{
perror("read");
break;
}
write (fd2,buf ,ret);
}
printf ("fuzhiwancheng\n");
close(fd1);
close(fd2);
return 0;
}
#include <fcntl.h>
#include <stdio.h>
#include<errno.h>
#include <unistd.h>
#define SIZE 1024
int main ()
{
int fd1=open ("1.ppt",O_RDONLY);
if (fd1==-1)
{
perror("open fd1");
}
int fd2=open("2.ppt",O_WRONLY|O_CREAT,0777);
if (fd1==-1)
{
perror("open fd2");
}
int ret=0;
char buf [SIZE]={0};
while (ret=read(fd1,buf,SIZE))
{
if (ret ==-1)
{
perror("read");
break;
}
write (fd2,buf ,ret);
}
printf ("fuzhiwancheng\n");
close(fd1);
close(fd2);
return 0;
}