Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   __FILE__ in Borland C++ (http://www.go4expert.com/forums/file-borland-cpp-t2564/)

ashish_onmobile 16Jan2007 08:58

__FILE__ in Borland C++
I am not sure how to get the absolute path from __FILE__ macro in Borland C++ Compiler. When I use it in my program I am only getting the file name. Is there some setting through which we can get the complete path. Please help ASAP.

shabbir 16Jan2007 09:43

Re: __FILE__ in Borland C++
Use the dot operator (.) to get the path to the current folder and join __FILE__ with it to get the complete path.

ashish_onmobile 16Jan2007 10:01

Re: __FILE__ in Borland C++
How am I supposed to use . operator in say a printf statement. Please illustrate.

shabbir 16Jan2007 11:00

Re: __FILE__ in Borland C++
printf would not solve the issue but you can use to open a file in the current folder and get its path and then print it. I am not sure about the Borland but its a general way of doing thing.

DaWei 16Jan2007 19:10

Re: __FILE__ in Borland C++
Not sure about Borland, but if you set your compiler options to "use full path" (there's often a command-line equivalent), then __FILE__ includes the path.

ashish_onmobile 18Jan2007 09:21

Re: __FILE__ in Borland C++
I figured out that one way of doing this would be to make use of the GetFullPathName function provided by the Windows SDK. :-)

findingit 18Jan2007 11:32

Re: __FILE__ in Borland C++
you can use GetModuleName get the application full path,then get the dir from it ,..

findingit 18Jan2007 11:33

Re: __FILE__ in Borland C++

All times are GMT +5.5. The time now is 11:24.