-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilehandling.cpp
68 lines (62 loc) · 1.21 KB
/
filehandling.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a<b) ? (a) : (b))
#define max(a,b) ((a>b) ? (a) : (b))
#define abs(a) ((a>0) ? (a) : ((-1)*a))
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORL(i,n) for(long long i=0;i<n;i++)
#define MOD 1000000007
#define PI 3.141592653589
#define pb push_back
#define mp make_pair
int dp[5009][5009]={0};
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define MAX_CHILD 5
#define null NULL
#define square(a) a*a
class hello{
public:
int id;
long long x;
hello()
{
id=0;
x=0;
}
hello(int i, ll x1)
{
id=i;
x=x1;
}
};
int main()
{
//fastio
//WRITING
/*
fileio
fstream t;
hello h(1,200000);
cout<<sizeof(h)<<endl;
t.open("test.txt",ios::in | ios::out | ios::ate);
if(t.is_open())
{
t.write((char*)&h , sizeof(hello));
cout<<t.tellp();
t.close();
}
else
cout<<"error";
*/
//READING
fstream t;
t.open("test.txt",ios::in | ios::out);
cout<<t.tellp()<<" "<<t.tellg();
hello h;
t.read((char*)&h, sizeof(hello));
cout<<t.tellp()<<" "<<t.tellg();
cout<<h.id;
return 0;
}