Thread: I/O--Using a variable as a filename

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Compile Errors = Schwa?!
    Join Date
    Aug 2005
    Location
    Ohio
    Posts
    15
    Code:
    FileName = FindStudent += ".txt";
    ofstream StudentName( FileName.c_str() );
    that should be what your looking for, I just learned this same stuff yesterday. That will search for that filename in the same directory as where the program is being run from. I'm currently trying to figure out how to have it search in other "child" folders of the folder the program is running from.


    ***EDIT: that is if your opening the file to write to it, use:

    Code:
    ifstream StudentName( FileName.c_str() );
    
    //In place of:
    
    ofstream StudentName( FileName.c_str() );
    
    //If you want to read from the file
    Last edited by Howie17; 09-03-2005 at 09:38 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Variable file names in file i/o
    By jesseee in forum C++ Programming
    Replies: 2
    Last Post: 01-15-2009, 09:58 AM
  2. Pass Filename to another function
    By awesmesk8er in forum C Programming
    Replies: 9
    Last Post: 10-24-2008, 01:43 PM
  3. Using a variable for a filename
    By Unlockitall in forum C++ Programming
    Replies: 4
    Last Post: 12-15-2007, 10:41 AM
  4. asynchronized I/O == multiplexing I/O?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 07-24-2006, 10:06 AM
  5. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM