How to store file in current directory

This is a discussion on How to store file in current directory within the C++ Programming forums, part of the General Programming Boards category; I know by writing this Code: ofstream school_file ("C:\Student_data.txt") a file name Student_data.txt will store in C drive. But how ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    42

    How to store file in current directory

    I know by writing this
    Code:
    ofstream school_file ("C:\\Student_data.txt")
    a file name Student_data.txt will store in C drive. But how do I store the file in the directory of the program run or current directory? Thanks in advance

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,742
    Remove the C:\\ part.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    42
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 11:39 PM
  2. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  3. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-22-2008, 12:19 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM

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