CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2008
    Posts
    12

    [Solved] File output name?

    I'm trying to make a program that will output a .DVD file with some data in it with a name the user inputs. However, I can't figure out how to have the user input some data into a string and then use that when creating the file. Here's how I have my function setup:

    Code:
    string filename;
         int layerbreak = 1913760;
         
         cout << "Please enter the name of the file: ";
         (cin >> filename).get();
         
         ofstream dvdfile("ASDF.DVD");
         if (dvdfile.is_open()){
    I have successfully made the .DVD file with the "ASDF" name, or whatever I put in the quotes... I just want to use the string stored in "filename" as the name of the .DVD file. Does anyone know how to do this? Thanks a lot in advance.
    Last edited by Silo1337; October 10th, 2008 at 12:12 PM.

  2. #2
    Join Date
    Feb 2003
    Posts
    377

    Re: File output name?

    Code:
    ofstream dvdfile(filename.c_str());
    In the current standard you can't pass an instance of the string class to an fstream constructor or open() function, you have to pass a C-style string.

  3. #3
    Join Date
    Jun 2008
    Posts
    12

    Re: File output name?

    Quote Originally Posted by jlou
    Code:
    ofstream dvdfile(filename.c_str());
    In the current standard you can't pass an instance of the string class to an fstream constructor or open() function, you have to pass a C-style string.
    Ah, it works. I appreciate your help, I suppose I need to read up more on file input output. Thanks!

  4. #4
    Join Date
    Feb 2003
    Posts
    377

    Re: File output name?

    Yeah... it's just one of those weird quirks of the language. They've already decided to fix it in the next standard.

  5. #5
    Join Date
    Jun 2008
    Posts
    592

    Re: File output name?

    Yeah... it's just one of those weird quirks of the language. They've already decided to fix it in the next standard.
    Good. I would think that should have been fixed a long time ago
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured