title: make a pwd type function in c
body: <p>I'm pulling my hair out here.  Its been about 1.5 years since I've done any c programming so bear with me.  </p>
  
  <p>I need to make a function in c that does what the pwd function does in linux.  I have a struct of nodes that represent a folder.  Each one has a pointer back to its parent so it should be pretty easy but I'm dying here.  I thought I could just keep using strcat to append the name of a nodes parent to the path name.  But, even if I was able to get this to work I would be left with a list that is in reverse, which is fine I guess.  I could at least deal with that.  But if I'm in directory c whose parent is b whose parent is a whose parent is root I should be able to use pwd to output the string "/a/b/c".  I'm stuck.  Any ideas?  When I try to use strcat I get segmentation faults up the ying yang.  </p>
  
  <pre><code>void pwd( ){  
  
      char *thePath;
      NODE *nodePtr;
      nodePtr = cwd;
  
      while( nodePtr != root ){
  
      }
      printf("%s\n", thePath);
      return;
  }   
  </code></pre>