title: How to get directory of a file which is called from command line argument?
body: <p>For example, I am calling my executable in ubuntu:</p>
  
  <p>./foo temp/game1.txt temp/game2 txt</p>
  
  <p>I am using realpath() to find the path to the game1.txt.
  Using it however will give me the full path including the game1.txt name.
  For example, it will come out as </p>
  
  <p>/home/<em>*</em>/Download/temp/game1.txt</p>
  
  <p>I want to erase game1.txt on that string so that I can use the string to use it to output other files in that folder.
  Two questions.</p>
  
  <ol>
  <li>Is realpath() alright to use for this kind of operation? Is there better way?</li>
  <li>Can someone give me a quick way to erase "game1.txt" so that the string will be "/home/<em>*</em>/Download/temp/" save in a string format(not char)?</li>
  </ol>
  
  <p>Thank you very much.</p>