This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: get a full line with ifstream


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]