Delete a file using C


/*
Write a progam in C to delete a file.
*/


#include<stdio.h>
#include<conio.h>

int main()
{
int status;
char fname[25];

printf("Enter the name of file you wish to delete ");
gets(fname);

status = remove(fname);

if( status == 0 )
printf("%s file deleted successfully\n",fname);
else
{
printf("Unable to delete the file\n");
perror("Error ");
}

getch();
return 0;
}



 

Post a Comment

0 Comments