Output file path

Hello everyone!

When we're using ofstreams, suppose we can create a file random.txt that would be in the same folder as the executable file. Say the .exe file is in the folder \Debug, we would find random.txt there too.
Now the path isn't absolute, even when you copy the .exe to say \Folder, we would find the text file there.
Question is: How can we know the "absolute" file path?

Thanks!
You can get the current directory and work out the relative difference from there.

It looks like you're using Windows, the call to get the current directory is: GetCurrentDirectory() (http://msdn.microsoft.com/en-us/library/aa364934%28VS.85%29.aspx). On Unix it's getcwd (http://opengroup.org/onlinepubs/007908799/xsh/getcwd.html)

Once you have the current directory, you can work out the absolute path to any relative directory spec.
Topic archived. No new replies allowed.