| | |
Ofstream Question
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
Hi, I have a question with ofstream, is there anyway to ask the user for a file name, then create the file, and write to it?
Like:
...except that doesn't work properly.
Thanks for any help.
Like:
C++ Syntax (Toggle Plain Text)
string file; cout << "Enter filename:"; getline(cin, file); ofstream ofile; ofile.open(file); ofile << (stuff....); ofile.close;
Thanks for any help.
C++ Syntax (Toggle Plain Text)
ofile.open(file.c_str()); ... ofile.close(); // function call!
fstream::open member function wants const char* argument only, not const std::string& . •
•
•
•
Hi, I have a question with ofstream, is there anyway to ask the user for a file name, then create the file, and write to it?
Like:
...except that doesn't work properly.C++ Syntax (Toggle Plain Text)
string file; cout << "Enter filename:"; getline(cin, file); ofstream ofile; ofile.open(file); ofile << (stuff....); ofile.close;![]()
Thanks for any help.
i.e.
C++ Syntax (Toggle Plain Text)
ofile.open(file.c_str());
Hope this is of some help,
Jas.
There are 10 types of people in this world.....
Those who understand binary .....
And those who don't!
Those who understand binary .....
And those who don't!
![]() |
Similar Threads
- C++ vector question? (C++)
- question on Stacks push,pop. (C++)
- ofstream (C)
- C++ question on classes (C++)
- File i/o question (C++)
- A question about file streaming (C++)
- fstream and struct question (C++)
Other Threads in the C++ Forum
- Previous Thread: terminating a process on vista
- Next Thread: a loop still iterating when its condition is broken
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






