Good day.

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

Found the rewind() and fseek(file,0L,SEEK_SET) , but they refuse to work if the file is not opened with the fopen function from the stdio.h library

Is there an alternative to the fstream library?

    1 answer 1

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