1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

__FILE__ in Borland C++

Discussion in 'C++' started by ashish_onmobile, Jan 16, 2007.

  1. ashish_onmobile

    ashish_onmobile New Member

    Joined:
    Jan 11, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    Use the dot operator (.) to get the path to the current folder and join __FILE__ with it to get the complete path.
     
  3. ashish_onmobile

    ashish_onmobile New Member

    Joined:
    Jan 11, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    How am I supposed to use . operator in say a printf statement. Please illustrate.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    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.
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    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.
     
  6. ashish_onmobile

    ashish_onmobile New Member

    Joined:
    Jan 11, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    I figured out that one way of doing this would be to make use of the GetFullPathName function provided by the Windows SDK. :)
     
  7. findingit

    findingit Banned

    Joined:
    Jan 17, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    you can use GetModuleName get the application full path,then get the dir from it ,..
     
  8. findingit

    findingit Banned

    Joined:
    Jan 17, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    GetModuleFileName
     

Share This Page