#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<ctype.h>
#include<stdio.h>
class telephone
{
public:
long tno;
char name[20];
void read()
{
cout<<"Enter telephone no";
cin>>tno;
cout<<"Enter Name";
gets(name);
}
void out()
{
cout<<"Telephone No:"<<tno;
cout<<"Name"<<name;
}
};
void search(long num)
{
telephone p;
int f=0;
ifstream in("tally.dat");
while(in.read((char *)&p,sizeof(p)))
{
if(num==p.tno)
{
f=1;
break;
}
}
if(f==1)
{
p.out();
}
else
{
cout<<"Match not found";
}
}
void main()
{
telephone p;
long no;
ofstream out("tally.dat",ios::binary|ios::app);
p.read();
out.write((char*)&p,sizeof(p));
out.close();
cout<<"Enter teleno. you want to search";
cin>>no;
search(no);
getch();
}
#include<conio.h>
#include<fstream.h>
#include<ctype.h>
#include<stdio.h>
class telephone
{
public:
long tno;
char name[20];
void read()
{
cout<<"Enter telephone no";
cin>>tno;
cout<<"Enter Name";
gets(name);
}
void out()
{
cout<<"Telephone No:"<<tno;
cout<<"Name"<<name;
}
};
void search(long num)
{
telephone p;
int f=0;
ifstream in("tally.dat");
while(in.read((char *)&p,sizeof(p)))
{
if(num==p.tno)
{
f=1;
break;
}
}
if(f==1)
{
p.out();
}
else
{
cout<<"Match not found";
}
}
void main()
{
telephone p;
long no;
ofstream out("tally.dat",ios::binary|ios::app);
p.read();
out.write((char*)&p,sizeof(p));
out.close();
cout<<"Enter teleno. you want to search";
cin>>no;
search(no);
getch();
}