Radu Vlad
Radu Vlad

Reputation: 1514

Read ASCII and binary from file in c++

How can i manage to open a file and read some fixed (lets assume n) lines of ASCII code, and after that switch to reading BINARY from the same file starting with the n+1 line in C++?

Upvotes: 0

Views: 801

Answers (1)

perreal
perreal

Reputation: 98118

You can't change the mode without reopening because the fstream uses system calls to open files which in turn do not allow a mode change. You can use tellg / seekg to save and later restore the reading position, respectively.

Upvotes: 1

Related Questions