typedef struct { char c[20]; int i; } header; void foo(std::string s) { std::ifstream ifs(s.c_str(), std::ios_base::binary | std::ios_base::in); if (ifs) {
what is the point of filebuf ?
None, here.
I can't see why you're using it.
Until you do more complex operations, filebuf is an implementation detail†.
filebuf
† (Sort of.)