Topic: PB with ifstream and "space" in END-OF-FILE


Author: kanze@gabi-soft.de (James Kanze)
Date: Tue, 23 Oct 2001 16:45:29 GMT
Raw View
Patrick Fourcade <Patrick.Fourcade@imag.fr> wrote in message
news:<3BD51DD6.DB5B50C6@imag.fr>...

> If I have a
> ifstream Input;
> (even protected)
> and at the end of text file some space characters,
> Input.eof does not jump to one

I'm not sure I understand what you are asking.  The function
std::istream::eof() isn't supposed to jump anywhere.  If it returns
true, it means that the next access will fail.  If it returns false,
it doesn't mean anything.  It's not a very useful function.

To position the read point in the file, you can use seekg.  To
position at end of file, you do

    input.seekg( 0 , std::ios_base::end ) ;

> and furthermore the adresse of Input jump

> to Null
> when the last command is : Input << Word.

What do you mean by "jump" in this case?  What are you trying to do?

The address (in memory) of the object does not change. Be aware,
however, that there is an implicit operator to convert the object to a
void*.  This void* has no relationship with the address of the object,
however (which is obtained by &input); all that is guaranteed is that
it is null after a read fails, and non-null otherwise.

--
James Kanze                                   mailto:kanze@gabi-soft.de
Beratung in objektorientierer Datenverarbeitung --
                             -- Conseils en informatique orient   e objet
Ziegelh   ttenweg 17a, 60598 Frankfurt, Germany, T   l.: +49 (0)69 19 86 27

---
[ 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://www.research.att.com/~austern/csc/faq.html                ]





Author: Patrick Fourcade <Patrick.Fourcade@imag.fr>
Date: Tue, 23 Oct 2001 09:12:28 GMT
Raw View
Hello,

If I have a
ifstream Input;
(even protected)
and at the end of text file some space characters,
Input.eof does not jump to one and furthermore the adresse of Input jump

to Null
when the last command is : Input << Word.

Is someone have had the same problem ?
Thank you.
--
________________________________________________________________________

Patrick
Fourcade
Tel: +33 (0)4 76 57 45 73
ACROE
Fax: +33 (0)4 76 57 48 89
46, avenue Felix
Viallet
mailto:Patrick.Fourcade@imag.fr
38000 Grenoble -
France
http://www-acroe.imag.fr
         (Association pour le Creation et la Recherche sur les Outils
d'expression)

Rencontres Informatique et Cr=E9ation Artistique
Grenoble 10.11.01>18.11.01
http://www-acroe.imag.fr/rica2001/rica2001.html
________________________________________________________________________



---
[ 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://www.research.att.com/~austern/csc/faq.html                ]