Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving input file to user defined output file

Status
Not open for further replies.

Puritan2

Technical User
Jul 23, 2003
8
0
0
CA
Every example I've seen involved file stream objects either hardcodes the filename or when writing to file, merely hardcodes the input.

What I'm trying to do is open a pre-existing text file, have the user type in a file name, and save the data from the opened text file into the user-defined output file.

I have one function that opens the text file and another that creates a new output file. I have a third which reads the contents. I can display it on screen but not save it into the new output file.

Any help would be greatly appreciated.
 
The bits you need are
Code:
char filename[100];
cin >> filename;  // read a filename from the user
istream ifs(filename);  // open user specified input file

May be better to use a proper string, and add some error checking for general use.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top