In C++ binary file handling what does the syntax (file.read((char *)&vg, sizeof(vg))) mean?
(file.read((char *)&vg, sizeof(vg)))
The first argument is casting the array "vg" to a char pointer. sizeof(vg) returns the size of the array in bytes. A C++ way to do this would be
std::array<int, 10> vg{}; file.read(static_cast<char*>(vg.begin()), vg.size());
548k questions
547k answers
4 comments
86.3k users