title: How to get the path to the current file (pwd) in Linux from C?
body: <p>I'd like to know if it is somehow possible to run <code>system(&quot;pwd&quot;)</code> on the current DIR. So for example let's have this folder structure:</p>
  <pre><code>example
   &gt;test
    &gt;&gt;file
   &gt;test2
    &gt;&gt;file3
    &gt;&gt;file4
  </code></pre>
  <p>And with <code>opendir()</code> and <code>readdir()</code> I'll get  to <code>file3</code>, and I want to use <code>system(&quot;pwd&quot;)</code> to get the path <code>..../example/test2/file3</code>. Is this somehow possible, or will <code>pwd</code> return the path to <code>main.c</code> all the time?</p>