Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Program to implement searching in a text file
1. /* PROGRAM TO IMPLEMENT SEARCHING IN A TEXT FILE */
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
struct stu
{
int rollno;
char name[25];
float marks;
}s1;
void main()
{
clrscr();
int rn;
char found='n';
ifstream fin("stu.txt",ios::in);
cout<<"n ENTER ROLL.NO. TO BE SEARCHED FOR : ";
cin>>rn;
while(!fin.eof())
{ fin.read((char*)&s1,sizeof(s1));
if(s1.rollno==rn)
{
cout<<s1.name<<rn<<" has scored "<<s1.marks;
found='y';
break;
}
}
if(found=='n')
{
cout<<" ROLL.NO. NOT FOUND IN THE FILE !!!! "<<endl;
}
fin.close();
getch();
}
OUTPUT :-