Advertisement
EternalMugen

Untitled

Apr 6th, 2020
200
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 <string>
  3. #include <fstream>
  4.  
  5. int main()
  6. {
  7.     int a, i = 1;
  8.     std::cout<<"Enter number: "<<std::flush;
  9.     std::cin >> a;
  10.  
  11.     std::ofstream f("binary.txt", std::ios::binary);
  12.     while (i != a)
  13.     {
  14.         f.write((char *)&i, sizeof(short));
  15.         //std::cout << a << std::endl;
  16.         i++;
  17.     }
  18.     f.close();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement