blob: 6ee16de8fdeca3ef3921ffeeccf9d5053a9c9fb6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <iostream>
#include <fstream>
#pragma warning(disable:4996)
using namespace std;
struct Test
{
bool b;
int x;
};
int main()
{
{ //write
Test t = { true, 45 };
ofstream file("testObj.bat", ios::binary);
file.write((char*)&t, sizeof(t));
}
{ //read
Test t;
ifstream file("testObj.bat", ios::binary);
file.read((char*)&t, sizeof(t));
std::cout << t.b << " " << t.x << std::endl;
}
}
|