Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- struct test {
- int a;
- int b;//overall:8B
- };
- struct test2 {
- char ch;
- int num;//overall:8B
- };
- int GetFileLen(ifstream& f)
- {
- f.seekg(0, ios::end);//placing the pointer at the end of file
- int size = f.tellg();//pointer's position
- f.seekg(0, ios::beg);
- return size;
- }
- int main() {
- ifstream f("test.bat", ios::binary);
- int fileSize = GetFileLen(f);
- int arrayLen = GetFileLen(f) / sizeof(test2);
- test2* arr = new test2[arrayLen];
- f.read((char*)arr, fileSize);
- f.close();
- while (true)
- {
- };
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement