#include<iostream.h>
#include<conio.h>
#include<fstream.h>
class student
{
int roll;
char name[15];
public:
void show()
{
cout<<"\nRoll :"<<roll<<endl;
cout<<"\n Name :"<<name<<endl;
}
int ret_roll()
{
return(roll);
}
};
void main()
{
student s,x;
int r,flag=0;
cout<<"Enter the Roll No. to Perform Search: \n";
cin>>r;
ifstream fin("stu.dat");
while(fin)
{
fin.read((char*)&s,sizeof s);
if(s.ret_roll()==r)
{
x=s;
flag++;
break;
}
}
if(flag!=0)
{
cout<<"Queried Record is as Follows :\n";
cout<<"------------------------------------------------\n\n";
x.show();
}
else
cout<<"Queried Record does Not Exist. ";
getch();
}
It's an attempt to help all C.Sc. students (of Class 11 and 12). Search for your needs, for better search try labels (at right sidebar), and message your reviews and requests. Have a Pleasant Programming !! :)
Make Your Search Easy ! :) Use me
Friday, February 17, 2017
Searching a record in a data file :-
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment