include fstream include iostream include cstring int main auto myfile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <fstream>
#include <iostream>
#include <cstring>
int main()
{
auto myfile = std::fstream("file.binary", std::ios::out | std::ios::binary);
char buff[8];
double pi = 3.1415925;
std::memcpy(buff, &pi, 8);
myfile.write(buff, 8);
myfile.close();
}