Prog#230 A: copy command

/*
copy command
Program#230 A
*/
#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);
i=write(q,a,i);
close(p);
close(q);
}