title: Program crashes on fclose()
body: <p>My program crashes on this part of code:  </p>
  
  <pre><code>if(fclose(_device) != SUCCESS){  
      cerr &lt;&lt; "Output device library error CLOSING FILE\n";  
      exit(1);  
  }  
  </code></pre>
  
  <p>It doesn't print anything, and when i write instead this line:  </p>
  
  <pre><code>cout &lt;&lt; fclose(_device)&lt;&lt;endl;  
  </code></pre>
  
  <p>It doesn't print anything either, and just crashes my program with no further comments.  </p>
  
  <p>In an earlier part of my program, i initialize the file with this line:  </p>
  
  <pre><code>_device = fopen ((char*)filename , "a");  
  </code></pre>
  
  <p>What can cause such a crash to my program?</p>