title: Obtain directory of a file in C code
body: <p>This question may be a bit naive, but I'm wondering if it's possible to obtain the directory part of a filename in C code. For instance, say I have the following Linux file:</p>
  
  <p>/home/user/Documents/Work/report.txt</p>
  
  <p>and I want to obtain the string "/home/user/Documents/Work/"</p>
  
  <p>Are there any C functions to do such a thing? Also, even though I gave a Linux file as an example, I'd like to be able to obtain the directory listing of a file on any OS.</p>
  
  <p>Thank you in advance.</p>