This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: get a full line with ifstream
- To: Heinke Frerichs <42 dot 41551 at gmx dot de>
- Subject: Re: get a full line with ifstream
- From: Rich Churcher <churchmouse at optusnet dot com dot au>
- Date: Wed, 5 Jan 2000 16:59:54 +1100
- Cc: gcc at gcc dot gnu dot org
- References: <387291DA.5A430302@gmx.de>
On Wed, 05 Jan 2000, Heinke Frerichs wrote:
> Hello,
> I'm new to this list and I don't know if I'm right here to ask this
> question, but I try.
> I need to read a full line with fstream, in other words, how to skip
> blank-characters?
> Can anybody help me with this? I'm sure there is an easyer way to do
> this than reading char for char until one is \n.
Hi :o) This really isn't a GCC question, and would probably be better
asked elsewhere (eg. comp.lang.c++, alt.comp.lang.learn.c-c++, etc.).
Briefly, there are a number of ways to do this. For std::string:
getline( streamname, stringname, '\n' );
For C-strings:
cin.getline( arrayname, arraysize, '\n' );
Alternatively, you can use istream_iterator or istreambuf_iterator. A
good C++ text like Stroustrup's "The C++ Programming Language" is the
best place to start learning this kind of thing.
Cheers,
--
Rich
churchmouse@optusnet.com.au
[ Please note new address. ]