Simple question about file I/O.

This is a discussion on Simple question about file I/O. within the C++ Programming forums, part of the General Programming Boards category; I just got done reading the file I/O tutorial, and i'm wondering, since the functions just create, add to, clear, ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Location
    Salisbury N.C.
    Posts
    20

    Simple question about file I/O.

    I just got done reading the file I/O tutorial, and i'm wondering, since the functions just create, add to, clear, or open files. Where do I need to place my files. I'm sorry I'm probably very confusing, but I mean....

    Say I want to use several files in my program, and I want them to be created in a common folder in a certain directory, is this possible?

    Like for example I want my program to create a folder (For example a 'myProgam' folder) and then create three files in it (c:\programfiles\myProgram)

    So, I'm just wondering if this is possible, and if so, how?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sure, just make the program use a path in the filename tha matches where you want to create the file. E.g.:
    Code:
    int main()
    {
        ifstream fin("c:\\temp\\myfile.txt");
    ...
    }
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Location
    Salisbury N.C.
    Posts
    20
    Ok, Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple file I/O problem
    By eecoder in forum C Programming
    Replies: 10
    Last Post: 10-17-2010, 12:00 AM
  2. C++ File I/O question
    By zero_cool in forum C++ Programming
    Replies: 3
    Last Post: 08-16-2005, 11:43 AM
  3. File I/O question... please help!
    By sirSolarius in forum C++ Programming
    Replies: 11
    Last Post: 10-07-2003, 09:30 AM
  4. File I/O Question
    By DocDroopy in forum C Programming
    Replies: 4
    Last Post: 08-02-2002, 09:58 AM
  5. I have a file I/O question as well
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 04:11 PM

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