File Stream problem ....

  • Thread starter Thread starter lavu
  • Start date Start date
L

lavu

I am trying to use filestreams (ifstream / ofstream) to copy
a text file line by line except except the last few lines that meet
certain conditions.
Each line is of variable length.
With the line length unknown, I used a fixed byte length buffer of 255
characters that I
copy over using getline(). However this removes the newline at the end
of the line and copies over
whatever value I have intialized the receving buffer.

what would be a clean way to copy over a line including a newline from
one file to another ?
Any help is appreciated.
 
lavu said:
I am trying to use filestreams (ifstream / ofstream) to copy
a text file line by line except except the last few lines that meet
certain conditions.
Each line is of variable length.
With the line length unknown, I used a fixed byte length buffer of 255
characters that I
copy over using getline(). However this removes the newline at the end
of the line and copies over
whatever value I have intialized the receving buffer.

what would be a clean way to copy over a line including a newline from
one file to another ?
Any help is appreciated.

To be perfectly honest, a scripting language such as Perl would be a much
better choice for this task. The whole program would be about five lines.
 
Back
Top