Location of ofstream

This is a discussion on Location of ofstream within the C++ Programming forums, part of the General Programming Boards category; When using Code: ifstream a_file("text.txt"); where does the text.txt file have to be located in order for it to be ...

  1. #1
    jed
    jed is offline
    Registered User
    Join Date
    Aug 2006
    Posts
    17

    Location of ofstream

    When using
    Code:
     ifstream a_file("text.txt");
    where does the text.txt file have to be located in order for it to be read?

  2. #2
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Directory of which the program is.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Directory of which the program is.
    I always thought it was the directory from which you are running the program.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    It is the current working directory, which might be the directory the exe resides in, or it might be the directory from which you run the program, or it might be neither.

  5. #5
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    What element determines working directory? (in Windows) And how can we change it in our program? Is there any API function?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >What element determines working directory? (in Windows)
    _getcwd

    >And how can we change it in our program?
    _chdir
    My best code is written with the delete key.

  7. #7
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>Is there any API function?<<

    SetCurrentDirectory and GetCurrentDirectory.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  8. #8
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    Why there is no <cdirect>?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    direct.h is not a standard C header, so it doesn't get updated to cdirect by the standard C++ library.

  10. #10
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    So what is it?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  11. #11
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    it stays <direct.h>

    that's if your compiler has it
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. instantiated from here: errors...
    By advocation in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2005, 08:01 AM
  2. I need help with templates!
    By advocation in forum C++ Programming
    Replies: 6
    Last Post: 03-26-2005, 08:27 PM
  3. Capturing key presses
    By cgod in forum Windows Programming
    Replies: 6
    Last Post: 11-25-2004, 12:10 PM
  4. Using ofstream in private of a class-errors
    By loobian in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2003, 09:06 PM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21