#include
#include
using namespace std;
struct student
{
char name[20];
int roll;
char phone[15];
};
int main()
{
student a;
ofstream f1("student.bin",ios::out|ios::binary);
for(int i=1;i<=3;i++)
{
cout<<"enter name,roll,phone number\n";
cin.getline(a.name,20);
cin>>a.roll;
cin.get();
cin.getline(a.phone,15);
f1.write((char*)&a,sizeof(a));
}
f1.close();
ifstream f("student.bin",ios::in|ios::binary);
f.seekg(0);
for(int i=1;i<=3;i++)
{
f.read((char*)&a,sizeof(a));
cout<
}
f.close();
}
No comments:
Post a Comment