File Manipulation

D

Darren

Hi All,

could anyone PLEASE halp me, i'm very new to c++, but i need to do the
following:

open data file
read file from X to Y
create a new file called X.txt
write data inbetween X and Y into file X.txt

just keep getting stuck at how to creta a file with a name known at runtime.

The names X.txt are call numbers, read from a data file, and the data is a
call log. Just want a way to split up the 1 huge file into individual files
with the name of teh call number.

All suggestiosn VERY welcome.

Many thanks,

Darren
 
J

Jon Bell

just keep getting stuck at how to creta a file with a name known at runtime.

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main ()
{
cout << "Enter the name of the output file: ";
string filename;
cin >> filename;

ofstream outfile (filename.c_str());
outfile << "fee fie foe fum" << endl;
outfile.close();

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top