#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
struct room
{
    char type[3];
    int rmn;
    int terrif;
};
void add(room *,int);
void main()
{
    clrscr();
    int n,r,modifychoice,c,a,i;
    room rm[5];
    cout<<endl<<endl;
    while(1)
    {
        cout<<"\t\t\t"<<"HOTEL DAVIANS"<<endl<<endl;
        cout<<"\t\t   "<<"MENU FOR HOTEL DAVIANS -"<<endl;
        cout<<"\t\t"<<"1. Enter rooms record for the hotel  "<<endl;
        cout<<"\t\t"<<"2. Modify rooms records"<<endl;
        cout<<"\t\t"<<"3. Check room records"<<endl;
        cout<<"\t\t"<<"4. Exit"<<endl<<endl<<endl;
        cout<<"enter choice: ";
        cin>>n;

        switch(n)
        {
            case 1: cout<<"enter no. of rooms in the hotel at present: ";
                cin>>r;
                for(int i=0;i<r;i++)
                {
                    cout<<"Details of room no."<<i+1<<endl;
                    cout<<"Room no.: ";
                    cin>>rm[i].rmn;
                    cout<<"Room type: ";
                    gets(rm[i].type);
                    fflush(stdin);
                    cout<<"Room terrif";
                    cin>>rm[i].terrif;
                }
                break;
            case 2:cout<<"Enter room no. to be modified: ";
                   cin>>i;
                   i=i-1;
                   clrscr();
                   while(1)
                   {
                   cout<<endl<<endl;
                   cout<<"\t\t"<<"1. Change room no."<<endl;
                   cout<<"\t\t"<<"2. Change room terrif"<<endl<<endl<<endl;
                   cout<<"\t\t"<<"Enter choice: ";
                   cin>>modifychoice;
                   if(modifychoice<3)
                   {
                   switch(modifychoice)
                   {
                    case 1:cout<<"Enter new room no.: ";
                           cin>>rm[i].rmn;
                    break;
                    case 2:cout<<"Enter new room terrif: ";
                           cin>>rm[i].terrif;
                    break;
                    default: cout<<"false option";
                   }
                   break;
                   }
                   clrscr();
                   }
            case 3:cout<<"Enter room no. whose record u want to see: ";
                   cin>>a;
                   i=a-1;
                   cout<<"Room no. is: "<<rm[i].rmn<<endl;
                   cout<<"Room type is: ";
                   puts(rm[i].type);
                   cout<<endl;
                   cout<<"Room terrif is: "<<rm[i].terrif;
            break;
            case 4:exit(0);
            default: cout<<"false option" ;
        }
        clrscr();
    }
    getch();
}

I m making a program running hotel menu ......... in which i have put options to add hotel record in 1st option and to see the entered records in 3rd option. When i select 1st option , i add record but when the loop again runs and i get the screen of menu again, i select 3rd option to see records but the record comes blank i.e. I m not able to see the added record again :( ............ What is the error in my coding regarding this ??

I m bonded to use concepts of structure, functions, arrays and basics of c++, not more than that. PLEASE HELP

This article has been dead for over six months. Start a new discussion instead.