* I am working on my attendance mini project .I want to check the string variable is entered in present in my file or not .There is problem in my check_data() function .Kindly help me out *
#include<fstream>
#include<iostream>
using namespace std;
class attend
{
int idn;
char ar[10];
public:
void getdata()
{
cout<<"ENTER THE ROLL NUMBER \n";
cin>>idn;
fstream fout("AT1.txt",ios::app);
fout<<"\n"<<idn;
cout<<"ENTER THE NAME "<<endl;
cin>>ar;
fout<<"\t"<<ar;
fout.close();
}
void check_data()
{
char i,chk[10];
cout<<"ENTER THE NAME TO CHECK "<<"\n";
cin>>chk;
fstream fin("AT1.txt",ios::in);
while(!fin.eof())
{
fin>>ar;
cout<<"\n"<<ar;
for(i=0;i<10;i++)
{
if(chk[i]==ar[i])
{
cout<<"DATA FOUND ";
}
}
}
}
};
int main()
{
attend obj;
obj.getdata();
obj.check_data();
}
Aucun commentaire:
Enregistrer un commentaire