Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For some reason I can not compile my code. I tried removing .h and adding \"usin

ID: 3860309 • Letter: F

Question

For some reason I can not compile my code. I tried removing .h and adding "using namespace std;" but nothing is working, help!

Dev-C++ 5.11

stdio: "No Such file or directory"

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <time.h>
#include <iomanip.h>
#include <fstream.h>
char fs[10]="fs";
char str[10]="str";
int address,adnm,fl,fs2,ire,nbv,uu,amount;
float amtT;
class Logon
{
public:
char pId[100];
char psswd[100];
char *pswsd;
void getPID()
{
cout<<"Enter your pId:";gets(pId);
pswsd=getpass("Enter the pswsd:");
strcpy(psswd,pswsd);
}
void dispPID()
{
cout<<"Id:";puts(pId);
cout<<"Password:";puts(psswd);
}
};
class details
{
public:
int trainNo;
char trainName[100];

char bo[100];
char dstntn[100];
int cot1,fare1;
int cot2,fare2;
int ire,nbv,ngo;
void getDetails()
{
cout<<"Enter the details as follows ";
cout<<"Train no:";cin>>trainNo;
cout<<"Train name:";gets(trainName);
cout<<"Boarding point:";gets(bo);
cout<<"Destination pt:";gets(dstntn);
cout<<"No of seats in first class & fare per ticket:";
cin>>cot1>>fare1;
cout<<"No of seats in second class & fare per ticket:";
cin>>cot2>>fare2;
cout<<"Date of travel:";cin>>ire>>nbv>>ngo;
}
void dispDetails()
{
cout<<trainNo<<" t"<<trainName<<" t"<<bo<<" t"<<dstntn<<" t";
cout<<cot1<<" t"<<fare1<<" t"<<cot2<<" t"<<fare2<<" t";
cout<<ire<<"-"<<nbv<<"-"<<ngo<<" t"<<endl;
}
};
class reservation
{
public:
int status;
int trainNo;
char trainName[100];
char bo[10];
char dstntn[100];
char pname[10][100];
int pAge[20];
char type[10];
int nosr;
int uu;
int ire,nbv,ngo;
int con;


float amc;
void ReservationDetails()
{
cout<<"Enter the details as follows ";
cout<<"Train no:";cin>>trainNo;
cout<<"Train name:";gets(trainName);
cout<<"Boarding point:";gets(bo);
cout<<"Destination pt:";gets(dstntn);
cout<<"No of seats required:";cin>>nosr;
for(uu=0;uu<nosr;uu++)
{
cout<<"Passenger name:";gets(pname[uu]);
cout<<"Passenger pAge:";cin>>pAge[uu];
}
cout<<"Enter the class fs-first class str-second class:";
gets(type);
cout<<"Date of travel:";cin>>ire>>nbv>>ngo;
cout<<"Enter the concession category ";
cout<<"1.Military 2.Senior citizen ";
cout<<"3.Children below 5 yrs 4.None ";
cin>>con;
cout<<"............END OF GETTING DETAILS............ ";
}
void dispReservationDetails()
{
cout<<"............................................... ";
cout<<"............................................... ";
cout<<"Pnr no:"<<status;
cout<<" Train no:"<<trainNo;
cout<<" Train name:";puts(trainName);
cout<<"Boarding point:";puts(bo);
cout<<"Destination pt:";puts(dstntn);
cout<<"No of seats reserved:"<<nosr;
for(uu=0;uu<nosr;uu++)
{
cout<<"Passenger name:";puts(pname[uu]);
cout<<"Passenger pAge:"<<pAge[uu];
}

cout<<" Your class:";puts(type);
cout<<" Date of reservation:"<<ire<<"-"<<nbv<<"-"<<ngo;
cout<<" Your concession category:"<<con;
cout<<" You must pay:"<<amc<<endl;
cout<<"*********************************************** ";
cout<<".........END OF RESERVATION................. ";
cout<<"*********************************************** ";
}
};
class cancellation
{
public:
int status;
int trainNo;
char trainName[100];
char bo[10];
char dstntn[100];
char pname[10][100];
int pAge[20];
int uu;
char type[10];
int nosc;
int ire,nbv,ngo;
float amr;
void getcancdet()
{
cout<<"Enter the details as follows ";
cout<<"Pnr no:";cin>>status;
cout<<"Date of cancellation:";cin>>ire>>nbv>>ngo;
cout<<"...........END OF GETTING DETAILS........... ";
}
void dispCanDetails()
{
cout<<"........................................... ";
cout<<"........................................... ";
cout<<"Pnr no:"<<status;
cout<<" Train no:"<<trainNo;
cout<<" Train name:";puts(trainName);
cout<<"Boarding point:";puts(bo);

cout<<"Destination pt:";puts(dstntn);
cout<<" Your class:";puts(type);
cout<<"no of seats to be cancelled:"<<nosc;
for(uu=0;uu<nosc;uu++)
{
cout<<"Passenger name:";puts(pname[uu]);
cout<<"passenger pAge:"<<pAge[uu];
}
cout<<" Date of cancellation:"<<ire<<"-"<<nbv<<"-"<<ngo;
cout<<" You cancellational collect:"<<amr<<"rs"<<endl;
cout<<"***************************************** ";
cout<<".........END OF CANCELLATION............. ";
cout<<"***************************************** ";
}
};
void man();
void cancellational();
void persons();
void db();
void reservational();
void reserved();
void displaypassdetail();
void cancelTicks();
void enq();
void main()
{
clrscr();
int choice;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ";
cout<<".......WELCOME TO RAILWAY RESERVATION SYSTEM.......... ";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ";
do
{
cout<<"^^^^^^^^^^^^^^^^^^^^^^MAIN MENU^^^^^^^^^^^^^^^^^^^^ ";
cout<<"1.Admin mode 2.User mode 3.Exit ";
cout<<"Enter your choice:";
cin>>choice;
cout<<endl;
switch(choice)

{
case 1:
db();
break;
case 2:
persons();
break;
case 3:
exit(0);
}
}while(choice<=3);
getch();
}
void db()
{
char *pswsd;
char *psswd="12345678";
pswsd=getpass("Enter the admininistrator pswsd:");
details dets;
fstream fs;
int choice;
char stu;
if(strcmp(psswd,pswsd)!=0)
{
cout<<"Enter the pswsd correctly ";
cout<<"You are not permitted to logon this mode ";
goto h;
}
if(strcmp(psswd,pswsd)==0)
{
char stu;
do
{
cout<<"...........ADMINISTRATOR MENU........... ";
cout<<"1.Create details data base 2.Add details ";
cout<<"3.Display details 4.User management ";
cout<<"5.Display passenger details 6.Return to main menu ";
cout<<"Enter your choice:";
cin>>choice;


cout<<endl;
switch(choice)
{
case 1:
fs.open("tt.txt",ios::out|ios::binary);
do
{
dets.getDetails();
fs.write((char *) & dets,sizeof(dets));
cout<<"Do you want to add one more record? ";
cout<<"ngo-for Yes n-for No ";
cin>>stu;
}while(stu=='ngo');
fs.close();
break;
case 2:
fs.open("tt.txt",ios::in|ios::out|ios::binary|ios::app);
dets.getDetails();
fs.write((char *) & dets,sizeof(dets));
fs.close();
break;
case 3:
fs.open("tt.txt",ios::in|ios::out|ios::binary|ios::app);
fs.seekg(0);
while(fs.read((char *) & dets,sizeof(dets)))
{
dets.dispDetails();
}
fs.close();
break;
case 4:
man();
break;
case 5:
displaypassdetail();
break;
}
}while(choice<=5);

fs.close();
}
h:
}
void reserved()
{
int choice;
do
{
cout<<"1.Reserve 2.Return to the main menu ";
cout<<"Enter your choice:";
cin>>choice;
cout<<endl;
switch(choice)
{
case 1:
reservational();
break;
}
}while(choice==1);
getch();
}
void reservational()
{
details dets;
reservation res;
fstream fs2,fs3;
time_t tt;
fs2.open("tt.txt",ios::in|ios::out|ios::binary);
fs3.open("p.txt",ios::in|ios::out|ios::binary|ios::app);
int choice;
res.ReservationDetails();
while(fs2.read((char *) &dets,sizeof(dets)))
{
if(dets.trainNo==res.trainNo)
{
if(strcmp(res.type,fs)==0)
{
if(dets.cot1>=res.nosr)

{
amount=dets.fare1;
address=fs2.tellg();
adnm=sizeof(dets.cot1);
fs2.seekp(address-(7*adnm));
dets.cot1=dets.cot1-res.nosr;
fs2.write((char *) & dets.cot1,sizeof(dets.cot1));
if(res.con==1)
{
cout<<"Concession category:MILITARY PERSONNEL ";

res.amc=res.nosr*((amount*50)/100);
}
else if(res.con==2)
{
cout<<"Concession category:SENIOR CITIZEN ";
res.amc=res.nosr*((amount*60)/100);
}
else if(res.con==3)
{
cout<<"Concession category:CHILDERN BELOW FIVE ";
res.amc=0.0;
}
else if(res.con==4)
{
cout<<"You cannot get any concession ";
res.amc=res.nosr*amount;
}
srand((unsigned) time(&tt));
res.status=rand();
fs3.write((char *) & res,sizeof(res));
res.dispReservationDetails();
cout<<"------------------------------------------------------ ";
cout<<"--------------Your ticket is reserved----------- ";
cout<<"-----------------End of reservation menu------- ";
}
else
{
cout<<"**********Sorry req seats not available******** ";

}
}
else if(strcmp(res.type,str)==0)
{
if(dets.cot2>=res.nosr)
{
amount=dets.fare2;
address=fs2.tellg();
adnm=sizeof(dets.cot2);
fs2.seekp(address-(5*adnm));
dets.cot2=dets.cot2-res.nosr;
fs2.write((char *) & dets.cot2,sizeof(dets.cot2));
if(res.con==1)
{
cout<<"Concession category:MILITARY PRESONNEL ";
res.amc=res.nosr*((amount*50)/100);
}
else if(res.con==2)
{
cout<<"Concession category:SENIOR CITIZEN ";
res.amc=res.nosr*((amount*60)/100);
}
else if(res.con==3)
{
cout<<"Concession category:CHILDERN BELOW FIVE ";
res.amc=0.0;
}
else if(res.con==4)
{
cout<<"You cannot get any concession ";
res.amc=res.nosr*amount;
}
fs3.write((char *) & res,sizeof(res));
res.dispReservationDetails();
cout<<"--------------------------------------- ";
cout<<"--------Your ticket is reserved-------- ";
cout<<"------------End of reservation--------- ";
}
else


{
cout<<"********Sorry req no of seats not available******* ";
}
}
getch();

goto h;
}
else
{
fl=0;
}
}
if(fl==0)
{
cout<<"............Wrong train no...................... ";
cout<<"......Enter the train no from the data base..... ";
}
fs2.close();
fs3.close();
getch();
h:
}
void displaypassdetail()
{
fstream fs;
reservation res;
fs.open("p.txt",ios::in|ios::out|ios::binary);
fs.seekg(0);
while(fs.read((char *) & res,sizeof(res)))
{
res.dispReservationDetails();
}
fs.close();
getch();
}
void enq()
{

fstream fs;
fs.open("tt.txt",ios::in|ios::out|ios::binary);
details dets;
while(fs.read((char *) & dets,sizeof(dets)))
{
dets.dispDetails();
}
getch();
}
void cancelTicks()
{
details dets;
reservation res;
cancellation stu;
fstream fs2,fs3,f3;
fs2.open("tt.txt",ios::in|ios::out|ios::binary);
fs3.open("p.txt",ios::in|ios::out|ios::binary);
f3.open("cn.txt",ios::in|ios::out|ios::binary);
cout<<"**********CANCELLATION MENU********* ";
stu.getcancdet();
while(fs3.read((char *) & res,sizeof(res)))
{
if(res.status==stu.status)
{
stu.trainNo=res.trainNo;
strcpy(stu.trainName,res.trainName);
strcpy(stu.bo,res.bo);
strcpy(stu.dstntn,res.dstntn);
stu.nosc=res.nosr;
for(int j=0;j<stu.nosc;j++)
{
strcpy(stu.pname[j],res.pname[j]);
stu.pAge[j]=res.pAge[j];
}
strcpy(stu.type,res.type);
if(strcmp(stu.type,fs)==0)
{
while(fs2.read((char *) & dets,sizeof(dets)))
{

if(dets.trainNo==stu.trainNo)
{
dets.cot1=dets.cot1+stu.nosc;
ire=dets.ire;
nbv=dets.nbv;
address=fs2.tellg();
adnm=sizeof(dets.cot1);
fs2.seekp(address-(7*adnm));
fs2.write((char *) & dets.cot1,sizeof(dets.cot1));
amtT=res.amc;
if((stu.ire==ire)&&(stu.nbv==nbv))
{
cout<<"You are cancelling at the date of departure ";
stu.amr=amtT-((amtT*60)/100);
}
else if(stu.nbv==nbv)
{
cout<<"You are cancelling at the month of departure ";
stu.amr=amtT-((amtT*50)/100);
}
else if(nbv>stu.nbv)
{
cout<<"You are cancelling one month before the date of departure ";
stu.amr=amtT-((amtT*20)/100);
}
else
{
cout<<"Cancelling after the departure ";
cout<<"Your request cannot be completed ";
}
goto h;
dispCanDetails();
}
}
}
else if(strcmp(stu.type,str)==0)
{
while(fs2.read((char *) & dets,sizeof(dets)))
{

if(dets.trainNo==stu.trainNo)
{
dets.cot2=dets.cot2+stu.nosc;
ire=dets.ire;
nbv=dets.nbv;
address=fs2.tellg();
adnm=sizeof(dets.cot2);
fs2.seekp(address-(5*adnm));
fs2.write((char *) & dets.cot2,sizeof(dets.cot2));
amtT=res.amc;
if((stu.ire==ire)&&(stu.nbv==nbv))
{
cout<<"You are cancelling at the date of departure ";
stu.amr=amtT-((amtT*60)/100);
}
else if(stu.nbv==nbv)
{
cout<<"You are cancelling at the month of departure ";
stu.amr=amtT-((amtT*50)/100);
}
else if(nbv>stu.nbv)
{
cout<<"You are cancelling one month before the date of departure ";
stu.amr=amtT-((amtT*20)/100);
}
else
{
cout<<"Cancelling after the departure ";
cout<<"Your request cannot be completed ";
}
goto h;
dispCanDetails();
}
}
}
}
else
{
fl=0;

}
}
h:
if(fl==0)
{
cout<<"Enter the correct status no ";
}
fs2.close();
fs3.close();
f3.close();
getch();
}
void cancellational()
{
int choice;
do
{
cout<<".................CANCELLATION MENU......... ";
cout<<"1.Cancel 2.Return to the main menu ";
cout<<"Enter your choice:";
cin>>choice;
cout<<endl;
switch(choice)
{
case 1:
cancelTicks();
break;
}
}while(choice==1);
getch();
}
void persons()
{
Logon dets;
int choice;
cout<<"***************************************************** ";
cout<<"***********WELCOME TO THE USER MENU** ";
cout<<"**************************************************** ";
char *pswsd;

fstream fs;
fs.open("pId.txt",ios::in|ios::out|ios::binary);
char pId[100];
puts("Enter your pId:");gets(pId);
pswsd=getpass("Enter your pswsd:");
while(fs.read((char *) & dets,sizeof(dets)))
{
if((strcmp(dets.pId,pId)==0)&&(strcmp(dets.psswd,pswsd)==0))
{
do
{
cout<<"1.Reserve 2.Cancell 3.Enquiry 4.Return to the main menu ";
cout<<"Enter your choice:";
cin>>choice;
cout<<endl;
switch(choice)
{
case 1:
reserved();
break;
case 2:
cancelTicks();
break;
case 3:
enq();
break;
}
}while(choice<=3);
goto j;
}
else
{
ire=1;
}
}
if(ire==1)
{
cout<<"Enter your persons pId and pswsd correctly ";
}

getch();
j:
}
void man()
{
int choice;
fstream fs;
char stu;
Logon dets;
cout<<".........WELCOME TO THE USER MANAGEMENT MENU........ ";
do
{
cout<<"1.Create pId data base 2.Add details ";
cout<<"3.Display details 4.Return to the main menu ";
cout<<"Enter your choice:";
cin>>choice;
cout<<endl;
switch(choice)
{
case 1:
fs.open("pId.txt",ios::out|ios::binary);
do
{
dets.getPID();
fs.write((char *) & dets,sizeof(dets));
cout<<"Do you want to add one more record ";
cout<<"ngo-Yes n-No ";
cin>>stu;
}while(stu=='ngo');
fs.close();
break;
case 2:
fs.open("pId.txt",ios::in|ios::out|ios::binary|ios::app);
dets.getPID();
fs.write((char *) & dets,sizeof(dets));
fs.close();
break;
case 3:
fs.open("pId.txt",ios::in|ios::out|ios::binary);

fs.seekg(0);
while(fs.read((char *) & dets,sizeof(dets)))
{
dets.dispPID();
}
fs.close();
break;
}
}while(choice<=3);
getch();
}

Explanation / Answer

Header parts being used deosnt exist in standard c++. they were part of some pre-1990s compilers, but it is certainly not part of C++.

conio.h is a C header file used in old MS-DOS compilers to create text user interfaces. Compilers that targeted non-DOS operating systems, such as Linux, Win32 and OS/2, provided different implementations of these functions. Same applies to iostream as well.

Remove .h and use #include <c> #include <iostream> instead. And all the library classes are in the std:: namespace, for ex­am­ple std::cout. Install required libraries .

Also how are you using the file , as .c or .cpp ? If it's a .c file, then your compiler may be interpreting it as C, and not C++. This could easily cause such an error. your default "include" directories for the standard library may not be set up right, but I don't know how you'd fix that, as that'd be compiler/environment dependent. try saving the file as .cpp and compile again.