title: C/C++ equivalent to Bash "readlink -f"
body: <p>I'm coding a Linux tool in C/C++ and receive a full path to a directory as input, this will always be rooted at "/" but elements of the path may be symlinks rather than real directories. For example:
  /tools/sometool/latest
  where "latest" is a symlink to "1.0".</p>
  
  <p>The path is then used to filter a list of other files. My problem is that the other files can use either form:
  /tools/sometool/latest/foo.txt
  /tools/sometool/1.0/foo.txt
  and I need to treat both as matching the criteria of being contained inside /tools/sometool/latest. I therefore need a way to fully resolve all the symlinks in the path.</p>
  
  <p>In Bash, "readlink -f /tools/sometool/latest" returns "/tools/sometool/1.0" which is perfect, but when I try "readlink()" in C, it just gives me "1.0".
  I've searched but can't find any existing solution to this in C.
  Is there a simple solution that I've missed, or do I need to build the equivalent of the bash command in C to make this work?</p>
  
  <p>Thanks!</p>
  
  <p>P.S. The tool doesn't need to be portable, so a Linux-only solution would be fine.</p>