Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #118579
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | fstreams |
| Date | 2024-03-27 15:11 +0000 |
| Organization | Stefan Ram |
| Message-ID | <streams-20240327161022@ram.dialup.fu-berlin.de> (permalink) |
This (barring typos) is from a book by Bjarne:
int main()
{
string from, to; /* get source and target file names */
cin >> from >> to;
ifstream is( from.c_str() ); /* open input stream */
ofstream os( to.c_str() ); /* open output stream */
istream_iterator<string> ii(is); /* make input iterator for stream */
istream_iterator<string> eos; /* input sentinel */
ostream_iterator<string> oo(os,"\n"); /* make out it. for stream */
set<string> b(ii, eos); /* b is a set initialized from input */
copy(b.begin(), b.end(), oo); /* copy buffer to output */ }
So, is this good style not checking the stream states after opening?
IIRC, out of the box those streams will not throw an exception
when they cannot open.
Back to comp.lang.c++ | Previous | Next | Find similar | Unroll thread
csiph-web