#include#include using namespace std; int main() { CFile file; file.Open("numbers.txt", CFile::modeRead); int num; file.ReadInt(&num); cout << "The first number in the file is: " << num << endl; file.Close(); return 0; }
#includeIn this example, we are reading two integer values from a binary file called "data.bin" using ReadInt(). The two values are stored in the variables num1 and num2 and then printed on the console. The CFile class is part of the MFC (Microsoft Foundation Class) library in C++.int main() { CFile file; file.Open("data.bin", CFile::modeRead); int num1, num2; file.ReadInt(&num1); file.ReadInt(&num2); cout << "The first number in the file is: " << num1 << endl; cout << "The second number in the file is: " << num2 << endl; file.Close(); return 0; }