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.

Discover more from PlusDigit

Subscribe to get the latest posts sent to your email.

Discover more from PlusDigit

Subscribe now to keep reading and get access to the full archive.

Continue reading

AdBlock Detected!

Please disable your AdBlocker to access this website.

Once disabled, this message will disappear automatically.