-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment 9.cpp
More file actions
50 lines (48 loc) · 948 Bytes
/
Assignment 9.cpp
File metadata and controls
50 lines (48 loc) · 948 Bytes
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
//============================================================================
// Name : frees.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<fstream>
using namespace std;
class student
{
string name;
int div;
public:
void input()
{
cout<<"Enter your name:";
cin>>name;
cout<<"Enter your division:";
cin>>div;
}
void print()
{
cout<<"Name: "<<name<<endl;
cout<<"Division: "<<div<<endl;
}
};
int main() {
student r[10];
int i,n;
cout<<"Enter limit:"<<endl;
cin>>n;
for(i=0;i<n;i++)
r[i].input();
ofstream o("com.txt",ios::binary);
for(i=0;i<n;i++)
o.write((char*)&r[i],sizeof(r[i]));
o.close();
ifstream ri("com.txt",ios::binary);
for(i=0;i<n;i++)
{
ri.read((char*)&r[i],sizeof(r[i]));
}
for(i=0;i<n;i++)
r[i].print();
return 0;
}