Click here to Skip to main content
16,004,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code

main()
{
int a;
char name[30];

   printf("enter the name of the file to be deleted");
   gets(name);
   a = remove(name);

   if(a == 0)
   {
      printf("the file has been deleted sucessfully");
   }
   else
   {
      printf("FILE NOT FOUND");
      perror("ERROR");
   }

  getch();
}
Posted
Updated 2-Oct-15 10:50am
v2

1 solution

Try changing,
a = remove(name);

to
a = remove("the_file_name"); //"the_file_name" is the name of the file you want to delete. 

Maybe this[^] link can add more clarification.
 
Share this answer
 
v2
Comments
[no name] 2-Oct-15 23:50pm    
Thank you for making my code to work but the output always goes for the else part of the program even if the file is present.Can you help me with this.
jeron1 3-Oct-15 11:50am    
How are specifying the file name (path).
[no name] 3-Oct-15 12:11pm    
a = remove("c:\test.txt");
jeron1 4-Oct-15 8:24am    
Try "c:\\test.txt" instead.
[no name] 4-Oct-15 9:19am    
Thank you for this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900