title: How do I lock files using fopen()?
body: <p>I wonder if there is any way to lock and unlock a file in Linux when I open a file using <code>fopen</code> (not <code>open</code>)?</p>
  
  <p>Based on Stack Overflow question <em><a href="https://stackoverflow.com/questions/1658476/c-fopen-vs-open">C fopen vs open</a></em>, <code>fopen</code> is preferred over <code>open</code>.</p>
  
  <p>How can I implement my own file lock (if possible) by creating and deleting lock files?</p>