Not compiling. Need help asap!!!

What am I doing wrong???
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<conio.h>
#include<fstream>
#include<dos.h>


void login();
void newrec();
void rec();
void update();
void rooms();
int check(int);
void modify(int);
void deleterec(int);
void updatefile();

typedef struct customer
{
int room_no;
char name[30];
char address[50];
char phone[10];
}rec1;



int main()

{
system ("color d");
printf (" ****************************************************************\n");
printf (" * ******************************************************** *\n");
printf (" * * ********************************* * *\n");
printf (" * * * T R A N Q U I L * * *\n");
printf (" * * * * * *\n");
printf (" * * * * * *\n");
printf (" * * * P A R A D I S E * * *\n");
printf (" * * * * * *\n");
printf (" * * * * * *\n");
printf (" * * * H O T E L * * *\n");
printf (" * * ********************************* * *\n");
printf (" * ******************************************************** *\n");
printf ("*****************************************************************\n");
system ("pause\n");
}

void login ()
{
system ("cls");
int count;
long int pass = {12345678};
printf ("Enter password\n\n");
scanf ("%d", &pass);

for (count=1; count <=1; count++)
{
if (pass == 12345678)
{
printf ("\n\nLoading...................\n\n");
system ("pause");
WelcomeScreen ();
}
else
{
printf ("Incorrect password. Try Again!!\n\n");
system ("pause");
login ();
}
}
}

char WelcomeScreen ()
{


printf (" *********************************************************************\n");
printf (" * *\n");
printf (" * W E L C O M E *\n");
printf (" * *\n");
printf (" * T O *\n");
printf (" * *\n");
printf (" * T R A N Q U I L P A R A D I S E H O T E L *\n");
printf (" * *\n");
printf (" * H O T E L M A N A G E M E N T S Y S T E M *\n");
printf (" * *\n");
printf (" * *\n");
printf ("**********************************************************************\n");
printf ("\n");
printf ("\n\tPlease select your option from the list below\n\n\n");
printf ("\t 1. Add new record\n");
printf ("\t 2. View Records\n")
printf ("\t 3. Update/Edit Record\n");
printf ("\t 4. View rooms availiable\n");
printf ("\t 5. Exit\n");
system ("pause\n");
system ("CLS");
printf ("Enter your option\n\n");
int choice;
scanf ("%d",&choice);

switch (choice)

{
case 1:newrec();
break;

case 2:rec();
break;

case 3:edit();
break;

case 4:rooms();
break;

default:
printf ("\n INVALID SELECTION\n");
system ("pause\n");
return 0;
}

void newrec()
{
clrscr();
int r,flag;
ofstream fout("Record.dat",ios::app);

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 rec()
{
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 Cusromer Details";
cout<<"\n ----------------";
cout<<"\n\n Room no: "<<room_no;
cout<<"\n Name: "<<name;
cout<<"\n Address: "<<address;
cout<<"\n Phone no: "<<phone;
flag=1;
break;
}
}

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

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

}


void rooms()
{
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();
}

void update()
{
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 Wrong Choice.....!!";
}
cout<<"\n Press any key to continue....!!!";
getch();
}


int 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 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();
}

void deleterec(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");
}
}
dopeking187 wrote:
What am I doing wrong???
You accidentally wrote #include <conio.h> and #include <dos.h> . These are non-standard headers and should not be used.

Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting.

Please copy and paste the exact error messages you are getting and indicate which lines they are on.
Last edited on
Topic archived. No new replies allowed.