title: Path to binary in C
body: <p>How can I get the path where the binary that is executing resides in a C program?</p>
  
  <p>I'm looking for something similar to <code>__FILE__</code> in ruby/perl/PHP (but of course, the <code>__FILE__</code> macro in C is determined at compile time).</p>
  
  <p><code>dirname(argv[0])</code> will give me what I want in all cases unless the binary is in the user's <code>$PATH</code>... then I do not get the information I want at all, but rather <code>""</code> or <code>"."</code></p>