title: Remove function not working
body: <p>I am trying to remove a file in my <code>C</code> program. So I first of all check whether the file exists and then if it does I use the remove function. Here is my code:</p>
  
  <pre><code>    if (!(f = fopen(position, "r")))
      {
          system("cls");
          printf("User does not exist! Please enter the user again: ");
      }
      else
      {
          status = remove(position);
  
          /*Check if file has been properly deleted*/
          if(status == 0)
          {
              printf("User deleted successfully.\n\n");
              break;
          }
          else
          {
              printf("Unable to delete the user\n");
          }
      }
  </code></pre>
  
  <p>Surely if the file definitely exists there should be no problem with removing the file. Anyway this bit of code is not working. And I just get returned <code>"Unable to delete the user"</code></p>
  
  <p>I have also tried using unlink along with importing <code>unistd.h</code> but no luck.</p>
  
  <p>What am I doing wrong?</p>