File Stream problem ....

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.
 
B

Ben Voigt

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.
 

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

Top