My goal as of right now is to pull out one customer by comparing the user name and password, called user and pass respectively. I have figured out a way to write to the file so as not to overwrite already existing users and to prevent people from having the same user name. However when I try to pull out one user using this bit of code...
std::fstream customerData;
customerData.open("customerData.dat",ios::in|ios::binary);
if(customerData.fail())
{
cout<<"Cannot connect to customer data right now\n";
system("pause");
}
customerData.seekg(0L,ios::beg);
customerData.seekp(0L,ios::beg);
for(int temp=0;temp<1000;temp++)
{
customerData.read((char*)&gatherd,sizeof(customerInfo));
if((gatherd.user==userName)&&(gatherd.pass==password))
{
temp=1001;
customer.credit=gatherd.credit;
customer.mail=gatherd.mail;
customer.movieOut=gatherd.movieOut;
customer.oneOut=gatherd.oneOut;
}
//Just after the if statement is where it crashes.
}
cout<<"Welcome "<<gatherd.user<<"!\n";
system("pause");
customerData.close();
}
...It crashes at the same spot every time. Just after the if statement. The program compiles fine. userName and password are of type string and are taken in by the function. Any help would be greatly appreciated! I've been at this for to long now and the program is due in...two hours ago :0!
P.S. gatherd is of type customerInfo as is customer.