日期:2014-05-16 浏览次数:21199 次
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
void filecopy(int fd1,int fd2);
int main(int argc, char *argv[])
{
int fd1,fd2;
if (3 != argc)
return -1;
if ((fd1 = open(argv+1,O_RDONLY,0)) == -1)
return -2;
if ((fd2 = open(argv+2,O_RDONLY,0)) == -1)
return -2;
filecopy(fd1,fd2);
}
void filecopy(int fd1,int fd2)
{
int n;
char *str[100];
while ((n = read(fd1,str,100)) !=-1 && n != 0 )
write(1,str,n);
while ((n = read(fd2,str,100)) != -1 && n != 0)
write(1,str,n);
}