I have a file txt file with the contents
10031James Cameron2346789Spanish TownSt.Catherine12 Clover CrescentDeluxeSinglePassport
I want to read from the file baesd on a seraching fro the id number and returning the datat to a class. But it seems I can't read from the file.
Heres is the code below.
void Cancel()
{
int idnumber;
int contact;
char name[100];
char country[100];
char street[100];
char parish[100];
char category[100];
char booking[100];
char idtype[100];
int reserveid=0;
cout<<"Please enter the guest ID you wish to cancel:";
cin>>reserveid;
guest info1;
ifstream file ;
file.open("guest.txt", ios::in) ;
file.seekg(0,ios::beg) ;
int found = 0 ;
while (!file.eof())
{
//file.read(reinterpret_cast<char *>(&info1),sizeof(guest));
file>>idnumber;
file>>name;
file>>contact;
file>>street;
file>>parish;
file>>country;
file>>booking;
file>>category;
file>>idtype;
guest info1(idnumber,contact,name,street,parish,country,booking,category,idtype);
if ( reserveid == idnumber )
found = 1 ;
info1.display();
}
file.close() ;
cout<<"\n";
system("pause");
}