return a line back to the stream

T

toton

Hi,
I am parsing a file, and while reading I use getline to read a line
from the stream. However if I found the line contains a specific
format like "START", then I want to push it back into the stream so
that the next processing unit get "START" while calling getline.
How to pushback a like which was already read from the stream to the
stream?
Standard io library supports this? or any additional library needed?


Thanks in advance ...

abir
 
E

Eric Pruneau

toton said:
Hi,
I am parsing a file, and while reading I use getline to read a line
from the stream. However if I found the line contains a specific
format like "START", then I want to push it back into the stream so
that the next processing unit get "START" while calling getline.
How to pushback a like which was already read from the stream to the
stream?
Standard io library supports this? or any additional library needed?


Thanks in advance ...

abir

Check for the putback function or unget in istream

eric
 
I

Ivan Vecerina

: I am parsing a file, and while reading I use getline to read a line
: from the stream. However if I found the line contains a specific
: format like "START", then I want to push it back into the stream so
: that the next processing unit get "START" while calling getline.
: How to pushback a like which was already read from the stream to the
: stream?
: Standard io library supports this? or any additional library needed?
No. You can reliably return a single char back into the stream,
but nothing more.
If you need to be able to buffer a complete line,
you need to handle this manually in a small wrapper.

hth -Ivan
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top