Prog#230 B: copy command


#1
/*
copy command
Program#230 B
*/
#include<stdio.h>
main(int argc,char *argv[])
{
int p,i,q;
char a[512];
if(argc!=3)
{
printf("error: no.of arg");
return 0;
}
p=open(argv[1], 0);
if(p==-1)
{
printf("file open error");
return 0;
}
q=open(argv[2], 1);
if(q==-1)
{
printf("file open error");
return 0;
}
i=read(p,a,512);
while(i>0)
{
i=write(q,a,i);
i=read(p,a,512);
}
close(p);
close(q);
}