title: "Error deleting file: Permission denied" with remove in C++
body: <p>When I compile and run my C++ program that deletes a file called example.txt (below)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main ()
  {
    if( remove( "example.txt" ) != 0 )
      perror( "Error deleting file" );
    else
      puts( "File successfully deleted" );
    return 0;
  }
  </code></pre>
  
  <p>It comes out like this...</p>
  
  <pre><code>cd c:\Users\Mark\Desktop  
  C:\Users\Mark\Desktop&gt;app.exe  
  Error deleting file: Permission denied  
  </code></pre>
  
  <p>I lifted all restrictions on the file and there is full access to anyone (that should  include my program).</p>
  
  <p>Any solutions?</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>When I type in <code>del example.txt</code> on command prompt it works.</p>
  
  <p>Weird...</p>