Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 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 main() {
  13.     ofstream f("test.bat", ios::binary);
  14.     test obj = { 3,4 };
  15.     test2 obj = { 'a',4 };
  16.     f.write((const char*)&obj, sizeof(test));
  17.     f.write((const char*)&obj, sizeof(test2));
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement