Topic: [Q] istream_iterator and End-Of-Reading
Author: Alex Vinokur <alexander.vinokur@telrad.co.il>
Date: 1999/05/30 Raw View
Hi,
#include <vector>
#include <string>
#include <algorithm>
int main ()
{
vector<string> vs;
copy(istream_iterator<string>(cin),
istream_iterator<string>(),
back_inserter(vs));
return 0;
}
This program reads data until end-of-stream.
Can istream_iterator read data until something other
(for example, until `\n')?
Thanks in advance,
Alex
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kuehl@horn.fmi.uni-konstanz.de (Dietmar Kuehl)
Date: 1999/05/31 Raw View
Hi,
Alex Vinokur (alexander.vinokur@telrad.co.il) wrote:
: This program reads data until end-of-stream.
: Can istream_iterator read data until something other
: (for example, until `\n')?
No. But you can read a line into a 'string' and parse this 'string'
using an 'istringstream'. Since 'getline()' takes a character where to
stop as argument, this can be used for arbitrary characters ('\n' is
just the default).
--
<mailto:dietmar.kuehl@claas-solutions.de>
<http://www.informatik.uni-konstanz.de/~kuehl/>
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]