I cant find the error in this code. I wrote it so it could accept the room ID, the name of the customer and phone number.
Then after accepting it should check whether that room is booked or not. After that it will save to a file. But the error comes when it asks if they want to book another room it automatically exits. But i want it to go back to the function if the reply was y. Here's the code. //this function is to check if the room Id entered is already booked or not int checkRoom(int rID, Rooms r){ room.open("Booked_Rooms", ios::in); if(room.is_open()){ while(!room.eof()){ if(rID==r.roomID){ room.close(); return 1; }else{ room.close(); return 0; } } }else { room.close(); return 0; } } //this is the booking function int checkRoom(int rID, Rooms r){ room.open("Booked_Rooms", ios::in); if(room.is_open()){ while(!room.eof()){ if(rID==r.roomID){ room.close(); return 1; }else{ room.close(); return 0; } } }else { room.close(); return 0; } }