Code for Program that provides an example of binary files in C++ Programming
# include <iostream.h>
# include <conio.h>
# include <fstream.h>
class machine
{
char name[10];
longint phone;
public:
void getdata()
{
cout<<"ENTER THE NAME:->";
cin>>name;
cout<<"\nENTER THE PHONE NUMBER:->";
cin>>phone;
}
void show()
{
cout<<"\nTHE NAME IS:->"<<name;
cout<<"\nTHE PHONE NUMBER is:->"<<phone;
}
};
main()
{
machine m;
fstream file;
file.open("data",ios::ate|ios::in|ios::out|ios::binary);
file.seekg(0,ios::beg);
cout<<"\nTHE CONTENTS OF FILE ARE.\n";
while(file.read(char *)&m,sizeof(m))