Prog#248: delete a file


#1
/*
delete a file
Program#248
*/
#include<stdio.h>
main(int argc,char *argv[])
{
int i;
if(argc!=2)
{
printf("error: no.of arg");
return 0;
}
i=access(argv[1],0);
if(i!=0)
{
printf("file not exist");
return 0;
}
i=access(argv[1],0200);
if(i==0)
i=unlink(argv[1]);
else
{
chmod(argv[1],0200);
i=unlink(argv[1]);
}
if(i==0)
printf("file deleted");
}