Advertisement
Infiniti_Inter

57 3 (7)

May 14th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ofstream out("output.txt", ios::binary);
  10.     int n; cin >> n;
  11.     for (int i = 1; i <= n; ++i)
  12.         out.write((char*)&(i), sizeof(int));
  13.     out.close();
  14.     ifstream in("output.txt", ios::binary);
  15.     while (in.peek() != EOF)
  16.     {
  17.         int cur;
  18.         in.read((char*)&cur, sizeof(int));
  19.         cout << cur << ' ';
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement