Thread: filestream- can a path name be a variable

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    10

    Question filestream- can a path name be a variable

    when creating an output file stream is there any way to the path name a varible and the extention is three digits the first number represent the day of the week (mon, tues, etc) and the last represent the number of files created so everytime a new file is created of the same type it increments by one

  2. #2
    Unregistered
    Guest
    Yes it can

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    10
    can you advise me on how please

  4. #4
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537

    quick example

    Code:
    char fileName[20];
    
    cout << "Enter the txt file you would like to open: ";
    cin >> fileName;
    
    ofstream fileOut( fileName );
    
    if( fileOut )
    {
    cout << "Congrats, you have successfully opened the file!!\n";
    }
    else
    {
    cout << "Could not open file, nevermind its not your fault really.\n";
    }
    
    fileOut.close( )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to put a check on an extern variable set as flag
    By rebelsoul in forum C Programming
    Replies: 18
    Last Post: 05-25-2009, 03:13 AM
  2. Getting type
    By AngKar in forum C# Programming
    Replies: 3
    Last Post: 05-26-2006, 09:06 AM
  3. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  4. static class variable vs. global variable
    By nadamson6 in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2005, 03:31 PM
  5. Replies: 2
    Last Post: 04-12-2004, 01:37 AM