title: How to find the full path of the C++ Linux program from within?
body: <p>I have this requirement where I need to find the full path for the C++ program from within. For Windows, I have the following solution. The argv[0] may or may not contain the full path. But I need to be certain.</p>
  
  <pre><code>TCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], base[_MAX_FNAME], ext[_MAX_EXT];
  TCHAR fullPath[255+1];
  _splitpath(argv[0],drive,dir,base,ext);
  SearchPath(NULL,base,ext,255,fullPath,NULL);
  </code></pre>
  
  <p>What is the Linux (gcc) equivalent for the above code? Would love to see a portable code.</p>