#include#include #include int main() { std::string fileName = "example.bin"; BFile myFile(fileName.c_str()); std::cout << "File size is: " << myFile.GetSize() << " bytes." << std::endl; return 0; }
#includeThis program also opens a binary file called "example.bin", but instead of using BFile, it uses ifstream to read the file size. GetSize equivalent in this program is achieved by using seekg function, which moves the file pointer to the end of the file, and then tells the position of the file pointer using tellg function. Package/library: Standard Library.#include #include int main() { std::string fileName = "example.bin"; std::ifstream stream(fileName, std::ios::binary); stream.seekg(0, std::ios::end); std::cout << "File size is: " << stream.tellg() << " bytes." << std::endl; stream.close(); return 0; }