C /C++ Help: Custom file name .txt

Discussion in 'School Work Help' started by wongdavid, Apr 25, 2011.

  1. wongdavid

    wongdavid New Member

    3
    1
    0
    Anyone know how to create a string that stores the name that the user wants to use for it's txt file?
    In short cin>>string use it for string.txt
    This has some to do with C as well, using it's syntax i can't.
    Thanks in advance

    Edited:
    Just asked my classmates, they said use fstream, so i'll go and read more about how to use it.
     
    #1 wongdavid, Apr 25, 2011
    Last edited: Apr 27, 2011
  2. iiimj4everiii

    iiimj4everiii Well-Known Member

    211
    241
    0
    hmm i dont really think u can do that. well who am i kidding. im just a beginner too. but usually i just name the file at the spot.

    #include <fstream> //file stream directory

    ofstream outfile ("NameOfTheFile.txt");