Prog#221: copy command - copy 1 file to other

/*
copy command - copy 1 file to other
Program#221
*/
#include<stdio.h>
main(int argc,char *argv[])
{
int q,i,p;
char a;
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], 01);
if(q==-1)
{
printf("file open error");
return 0;
}
i=read(p,&a,1);
while(i>0)
{
i=write(q,&a,1);
i=read(p,&a,1);
}
close(p);
close(q);
}