i can not figure out a way to let the user save their own file name in the ofstream i tried to do this...
string SaveName;
std:: ifstream input("finale.txt");
std:: ofstream output(SaveName);
and then a prompt asking user for SaveName i know this doesn't work but i dont know what else to do..... this is very frustrating......
BlackPhoenixVII
0
Newbie Poster
Recommended Answers
Jump to PostUsing C-style strings:
#include <iostream> #include <fstream> #include <cstdio> ... char filename[FILENAME_MAX]; cout<<"Enter a filename to save to: "; cin.getline ( filename, sizeof filename ); ofstream output ( filename );
Using std::strings:
#include <iostream> #include <fstream> #include <string> ... string filename; cout<<"Enter a filename …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.