title: How to get path to current exe file on Linux?
body: <p>The code below gives current path to exe file on Linux:</p>
  
  <pre><code>#include &lt;iostream&gt;
  std::string getExePath()
  {
    char result[ PATH_MAX ];
    ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
    return std::string( result, (count &gt; 0) ? count : 0 );
  }
  int main()
  {
    std::cout &lt;&lt; getExePath() &lt;&lt; std::endl;  
    return 0;
  }
  </code></pre>
  
  <p>The problem is that when I run it gives me current path to exe and name of the exe, e.g.:</p>
  
  <pre><code>/home/.../Test/main.exe
  </code></pre>
  
  <p>I would like to get only </p>
  
  <pre><code>/home/.../Test/
  </code></pre>
  
  <p>I know that I can parse it, but is there any nicer way to do that?</p>