Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 08:39 PM
Darren
Guest
 
Posts: n/a
Default File Manipulation

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


  #2  
Old July 19th, 2005, 08:39 PM
Jon Bell
Guest
 
Posts: n/a
Default Re: File Manipulation

In article <P4ymb.639$R85.365@newsfep3-gui.server.ntli.net>,
Darren <foo.bar@world.com> wrote:[color=blue]
>
>just keep getting stuck at how to creta a file with a name known at runtime.[/color]

#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;
}

--
Jon Bell <jtbellap8@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles