Program to delete a file in C

c_logo







#include<stdio.h>

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

   printf("Enter the name of file you wish to deleten");
   gets(file_name);

   status = remove(file_name);

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

   return 0;
}

Output
Enter the name of file you wish to delete
hello.c
hello.c file deleted successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *