C++. Read the file twice. Fstream Library

Good time of day.

There was such a question. How can I read a file twice in the library fstream without closing it?

I found the functions rewind() and fseek(file,0L,SEEK_SET), but they refuse to work if you do not open the file with the function fopen from the library stdio.h

Is there an alternative for the fstream library?

Author: Harry, 2017-01-31

1 answers

Look at the seekg(). And, if you run into the end of the file or other troubles - do not forget to reset the error state using clear().

 5
Author: Harry, 2017-01-31 16:17:42