help

This is a discussion on help within the C++ Programming forums, part of the General Programming Boards category; the code Code: ofstream a_file("Data") creates a file in the same directory of the program, what can i do to ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220

    help

    the code
    Code:
    ofstream a_file("Data")
    creates a file in the same directory of the program, what can i do to exchange the directory? ty in advanced.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    add the full path to where you want the file, such as "c:\mydir\Data" for MS-Windows, or "/mydir/Data" for *nix.

  3. #3
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    But remember \ is used by c++, so to use a slash you have to 'escape' it first.
    For for one \, you have to put \\.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by Enahs
    But remember \ is used by c++, so to use a slash you have to 'escape' it first.
    For for one \, you have to put \\.
    Oops!

Popular pages Recent additions subscribe to a feed

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