title: How to delete and rename files in C on windows
body: <p>I am working on program which renames or deletes the files in the file system. I am using C and it works well on linux machine but fails on windows. i use gcc compiler suit. and following is the code it does not delete the files from my file system. </p>
  
  <p>Thanks in advance </p>
  
  <pre><code> #include&lt;stdio.h&gt;
  
  int main()
  {
   printf("Program demonstrating file renaming and file deletion. \n");
  
   printf("Enter file name to be deleted : ");
   char fdelete[25];
  
   fflush(stdin);
  
   gets(fdelete);
  
   printf("Enter file name to be renamed : ");
   char frename[25];
  
   fflush(stdin);
  
   gets(frename);
  
   if (remove(fdelete)!=0)
   { 
    printf("error deleting the file.\n");
   }
  
   if(rename("test2.txt",frename)!=0)   //test2.txt is the original file
   {
    printf("eeror renaming the file.\n");
   }
  
  return 0;
  }
  </code></pre>