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......

Using 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 to save to: ";
getline ( cin, filename );

ofstream output ( filename.c_str() );

thanx u have no idea how much this means to me.

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.