Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <vector>
  5. #include <thread>
  6. #include <chrono>
  7. using namespace std;
  8. #pragma pack(push,1)
  9.  
  10. struct long_struct {
  11.   double data1[99999];
  12.   long int data2[99999];
  13.   long int data3[99999];
  14. };
  15. #pragma pack(pop)
  16.  
  17. int main() {
  18.   string name = "file.bin";
  19.   ofstream out;
  20.  
  21.   out.open(name, ios::binary | ios::out | ios::trunc | ios::ate);
  22.   out.clear();
  23.   long_struct d1 = {};
  24.   d1.data1[0] = 1;
  25.  
  26.   // long_struct d2 = {};
  27.   // vector< long_struct> vec_tmp = { d1, d2 };
  28.   char *a;
  29.   long int size = 1000000000;
  30.   a = new char[size];
  31.   char end_char[10] { 'e', 'n', 'd', 'o', 'f', 'f', 'i', 'l', 'e' };
  32.  
  33.   chrono::steady_clock::time_point i = chrono::steady_clock::now();
  34.  
  35.   cout << "KILL NOW" << endl;
  36.  
  37.   out.write(reinterpret_cast<char *>(&d1), sizeof(d1));
  38.   // this_thread::sleep_for(chrono::milliseconds(1000));
  39.   out.write(a, size * sizeof(char));
  40.  
  41.   out.write(reinterpret_cast<char *>(&i), sizeof(i));
  42.   out.write(end_char, 10 * sizeof(char));
  43.   // out.write(reinterpret_cast<char *>(&data1), sizeof(data1));
  44.   // out.write(reinterpret_cast<char *>(&data2), sizeof(data2));
  45.   out.close();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement