Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. struct test {
  5.     int a;
  6.     int b;//overall:8B
  7. };
  8. struct test2 {
  9.     char ch;
  10.     int num;//overall:8B
  11. };
  12. int GetFileLen(ifstream& f)
  13. {
  14.     f.seekg(0, ios::end);//placing the pointer at the end of file
  15.     int size = f.tellg();//pointer's position
  16.     f.seekg(0, ios::beg);
  17.     return size;
  18. }
  19. int main() {
  20.     ifstream f("test.bat", ios::binary);
  21.     int fileSize = GetFileLen(f);
  22.     int arrayLen = GetFileLen(f) / sizeof(test2);
  23.     test2* arr = new test2[arrayLen];
  24.     f.read((char*)arr, fileSize);
  25.     f.close();
  26.     while (true)
  27.     {
  28.  
  29.     };
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement