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!

How to read a large file

Status
Not open for further replies.

csripriya1

Programmer
May 13, 2003
35
0
0
US
Hi all,
I want to read in a large file and then split into smaller files as per some pattern. I am using fstream in C++. My executable slows after some time. I am seraching a way to speed up this process. Can any one please help me with this.

My code is as follows.
ifstream inpfile(stra,ios::in);
if(!inpfile)
{
cerr<<"File could not be opened"<<endl;
exit(1);
}


ofstream outfile(outputfile,ios::eek:ut|ios::app);
if(!outfile)
{
cerr<<"File could not be opened"<<endl;
exit(1);
}
.......
in=1;
while(in<=limit1)
{
inpfile.getline(dummy,1000,'\n');
outfile<<dummy<<endl;
in++;
}
............

in=1;
while(in<=limit2)
{
inpfile.getline(dummy,1000,'\n');
outfile<<dummy<<endl;
in++;
}


Thank you very much for your time and effort in advance.
 
I cant see anything in the supplied code that would slow down execution progressively.
whast in the ... sections?

Have you tried profiling your code to see what is slowing it down?

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top