Here is the program to delete a file in C......
#include <stdio.h>
#include<stdio.h>
#include<errno.h>
int main(void)
{
char file[80];
int i;
clrscr();
printf("File to delete: ");
gets(file);
i=remove(file);
if(i==0)
{
printf("file removed");
}
else
{
if(errno==ENOENT)
printf("\nNo such file exists");
if(errno==EACCES)
printf("\nPermission denied");
}
getch();
return 0;
}
Feel Free to Comment if any point is not clear.........
i=remove(file);
ReplyDeletewat is this line indicates?
is remove is an inbulid function?
Yes It is a inbuilt function.The prototype for this is:
ReplyDeleteint remove(const char *filename);