thread stopped suddenly

there is no error when i compiled this code, but when i run it. it will automatically stop and show the CPU memory address. can someone figure out what the problem?


#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <conio.h>

fstream hotelFiles;
const int size = 3;
const int col = 1;

class hotel
{
//========================== customer variable declarations ==============
int room_no;
char name[30];
char address[30];
char phone[10];
int z;

char type[25];
float price;


//========================== staff menu ============================
public:
void main_menu(); //to display main menu
void staff_menu(); // to display staff menu
void cust_menu(); // to display customer menu

//================== staff role ====================================

void book_room(); //to book a room for cust
void display_rec(); // to display customer record
void edit(); //edit customer record
void modify(int); //to modify record
void delete_rec(int); //to delete cust record

void availability(); // to check room available or not
int room_info(); //to display room type and price

int check(int);

void getData();
float getPrice()
{
return price;
}


};


//============================= prompt user to select role =====================
void hotel::main_menu()
{

int apps;

cout << "\n\n\n\n\t\tSelect user : ";
cout << "\n\n\n\n\t\t1. Staff ";
cout << "\n\n\t\t2. Customer ";
cout<<"\n\n\t\tEnter Your Choice: ";
cin>>apps;

switch(apps)
{
case 1: staff_menu();
break;
case 2: cust_menu();
break;
default: cout<<"\n Wrong Choice.....!!";
}
cout<<"\n Press any key to continue....!!!";

getch();

}
void hotel::staff_menu()
{ clrscr();
int choice;
while(choice!=5)
{

cout<<"\n\t\t\t\t*************************";
cout<<"\n\t\t\t\t* STAFF MENU *";
cout<<"\n\t\t\t\t*************************";
cout<<"\n\n\n\n\t\t\t\t1.Book A Room";
cout<<"\n\n\t\t\t\t2.Display Customer Record";
cout<<"\n\n\t\t\t\t3.Check Availabilty";
cout<<"\n\n\t\t\t\t4.Edit Customer Record";
cout<<"\n\n\t\t\t\t5.Exit";
cout<<"\n\n\n\t\t\t\tEnter Your Choice: ";
cin>>choice;

switch(choice)
{
case 1: book_room();
break;
case 2: display_rec();
break;
case 3: availability();
break;
case 4: edit();
break;
case 5: break;
default:
{
cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
}
}
}
}
//===================================================================
void hotel::book_room()
{
clrscr();
int r,flag;
ofstream fout("Record.dat",ios::app); //ofstream:Stream class to write on files

cout<<"\n Enter Customer Detalis";
cout<<"\n ----------------------";
cout<<"\n\n Room no: ";
cin>>r;
flag=check(r);

if(flag)
cout<<"\n Sorry..!!!Room is already booked";

else
{
room_no=r;

cout<<" Name: ";
gets(name);

cout<<" Address: ";
gets(address);

cout<<" Phone No: ";
gets(phone);

fout.write((char*)this,sizeof(hotel));
cout<<"\n Room is booked...!!!";
}

cout<<"\n Press any key to continue.....!!";
getch();
fout.close();


}

//===================================================================
void hotel::display_rec()
{
clrscr();
ifstream fin("Record.dat",ios::in);

cout<<"\n\t\t\t List Of Rooms Allotted";
cout<<"\n\t\t\t ----------------------";
cout<<"\n\n Room No.\tName\t\tAddress\t\t\t\tPhone No.\n";

while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
cout<<"\n\n "<<room_no<<"\t\t"<<name;
cout<<"\t\t"<<address<<"\t\t"<<phone;
}
cout<<"\n\n\n\t\t\tPress any key to continue.....!!";
getch();
fin.close();
}

//===============================================================
int hotel::check(int r)
{

int flag=0;
ifstream fin("Record.dat",ios::in);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{
flag=1;
break;
}
}

fin.close();
return(flag);
}

//===================================================================
void hotel::availability()
{
clrscr();
ifstream fin("Record.dat",ios::in);

int r,flag;
cout<<"\n Enter room no: ";
cin>>r;

while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{
clrscr();
cout<<"\n Check Availabilty";
cout<<"\n ----------------";
cout<<"\n\n Room no: "<<room_no;

flag=1;
break;
}
}

if(flag)

cout<<"\n Sorry the room has been book or vacant....!!";

cout<<"\n\n Press any key to continue....!!";
getch();
fin.close();
}

//===================================================================
void hotel::edit()
{
clrscr();
int choice,r;

cout<<"\n EDIT MENU";
cout<<"\n ---------";
cout<<"\n\n 1.Modify Customer Record";
cout<<"\n 2.Delete Customer Record";

cout<<"\n Enter your choice: ";
cin>>choice;
clrscr();
cout<<"\n Enter room no: " ;
cin>>r;

switch(choice)
{
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
default: cout<<"\n Record Not Found.....!!";
}
cout<<"\n Press any key to continue....!!!";
getch();
}

//=================================modify record ==================
void hotel::modify(int r)
{
long pos,flag=0;
fstream file("Record.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
pos=file.tellg();
file.read((char*)this,sizeof(hotel));
if(room_no==r)
{
cout<<"\n Enter New Details";
cout<<"\n -----------------";
cout<<"\n Name: ";
gets(name);
cout<<" Address: ";
gets(address);
cout<<" Phone no: ";
gets(phone);

file.seekg(pos);
file.write((char*)this,sizeof(hotel));
cout<<"\n Record is modified....!!";
flag=1;
break;
}
}

if(flag==0)
cout<<"\n Sorry Room no. not found or vacant...!!";
file.close();
}

//============================ delete record =========================
void hotel::delete_rec(int r)
{
int flag=0;
char ch;
ifstream fin("Record.dat",ios::in);
ofstream fout("temp.dat",ios::out);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{
cout<<"\n Name: "<<name;
cout<<"\n Address: "<<address;
cout<<"\n Pone No: "<<phone;
cout<<"\n\n Do you want to delete this record(y/n): ";
cin>>ch;

if(ch=='n')
fout.write((char*)this,sizeof(hotel));
flag=1;
}
else
fout.write((char*)this,sizeof(hotel));
}

fin.close();
fout.close();
if(flag==0)
cout<<"\n Sorry room no. not found or vacant...!!";
else
{
remove("Record.dat");
rename("temp.dat","Record.dat");
}
}

//===================================================================
void hotel::cust_menu()
{
clrscr();
int cust;
while(cust!=3)
{

cout<<"\n\t\t\t\t****************************";
cout<<"\n\t\t\t\t* CUSTOMER MENU *";
cout<<"\n\t\t\t\t****************************";
cout<<"\n\n\n\n\t\t\t\t1.Display Room Info";
cout<<"\n\n\t\t\t\t2.Check Availabilty";
cout<<"\n\n\t\t\t\t3.Exit";
cout<<"\n\n\n\n\t\t\t\tEnter Your Choice: ";
cin>>cust;

switch(cust)
{
case 1: room_info();
break;
case 2: availability();
break;
case 3: break;
default:
{
cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
}
}
}
}

//=============================== room info =================
int hotel::room_info()
{

hotelFiles.open("hotel2.txt", ios::in);

hotel myHotel[size][col];
//invoke default constructor
for (int j=0;j<size;j++)
for (int k=0;k<col;k++)
myHotel[j][k].getData();



for (int j=0;j<size;j++)
for (int k=0;k<col;k++)
myHotel[j][k].room_info();


hotelFiles.close();

cout << "\n\n\t\t"<< type <<"\t\t"<< price;



}

//==========================================================
void hotel::getData()
{
hotelFiles >> room_no >> price;
hotelFiles.get(type, 25);
hotelFiles.ignore(80,'\n');
}


//==================== main ================================

main()
{
hotel h;

cout<<"\n\t\t\t****************************";
cout<<"\n\t\t\t* HOTEL MANAGEMENT PROJECT *";
cout<<"\n\t\t\t****************************";





getch();

h.main_menu();


}
why anyone don't want to help me? T_T
Topic archived. No new replies allowed.