|
-
October 10th, 2008, 11:47 AM
#1
[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.
-
October 10th, 2008, 11:59 AM
#2
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.
-
October 10th, 2008, 12:06 PM
#3
Re: File output name?
 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!
-
October 10th, 2008, 12:12 PM
#4
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.
-
October 10th, 2008, 12:54 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|