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

This is a program for a simple library system. My question is how do you get thi

ID: 3813976 • Letter: T

Question

 This is a program for a simple library system.  My question is how do you get this to work on a linux machine?  Conio doesn't work and i'm pretty sure process.h doesn't either.  I've heard about the curses library but I have no idea on how to do that.   #include<fstream.h> #include<conio.h> #include<stdio.h> #include<process.h> #include<string.h> #include<iomanip.h> 
 class book {         char bno[6];         char bname[50];         char aname[20];   public:         void create_book()         {                 cout<<" NEW BOOK ENTRY... ";                 cout<<" Enter The book no.";                 cin>>bno;                 cout<<"  Enter The Name of The Book ";                 gets(bname);                 cout<<"  Enter The Author's Name ";                 gets(aname);                 cout<<"   Book Created..";         }          void show_book()         {                 cout<<" Book no. : "<<bno;                 cout<<" Book Name : ";                 puts(bname);                 cout<<"Author Name : ";                 puts(aname);         }          void modify_book()         {                 cout<<" Book no. : "<<bno;                 cout<<" Modify Book Name : ";                 gets(bname);                 cout<<" Modify Author's Name of Book : ";                 gets(aname);         }          char* retbno()         {                 return bno;         }          void report()         {cout<<bno<<setw(30)<<bname<<setw(30)<<aname<<endl;}   };         //class ends here     class student {         char admno[6];         char name[20];         char stbno[6];         int token; public:         void create_student()         {                 clrscr();                 cout<<" NEW STUDENT ENTRY... ";                 cout<<" Enter The admission no. ";                 cin>>admno;                 cout<<"  Enter The Name of The Student ";                 gets(name);                 token=0;                 stbno[0]='/0';                 cout<<"  Student Record Created..";         }          void show_student()         {                 cout<<" Admission no. : "<<admno;                 cout<<" Student Name : ";                 puts(name);                 cout<<" No of Book issued : "<<token;                 if(token==1)                         cout<<" Book No "<<stbno;         }          void modify_student()         {                 cout<<" Admission no. : "<<admno;                 cout<<" Modify Student Name : ";                 gets(name);         }          char* retadmno()         {                 return admno;         }          char* retstbno()         {                 return stbno;         }          int rettoken()         {                 return token;         }          void addtoken()         {token=1;}          void resettoken()         {token=0;}          void getstbno(char t[])         {                 strcpy(stbno,t);         }          void report()         {cout<<"	"<<admno<<setw(20)<<name<<setw(10)<<token<<endl;}  }; 
 fstream fp,fp1; book bk; student st; 
 void write_book() {         char ch;         fp.open("book.dat",ios::out|ios::app);         do         {                 clrscr();                 bk.create_book();                 fp.write((char*)&bk,sizeof(book));                 cout<<"  Do you want to add more record..(y/n?)";                 cin>>ch;         }while(ch=='y'||ch=='Y');         fp.close(); }  void write_student() {         char ch;         fp.open("student.dat",ios::out|ios::app);         do         {                 st.create_student();                 fp.write((char*)&st,sizeof(student));                 cout<<"  do you want to add more record..(y/n?)";                 cin>>ch;         }while(ch=='y'||ch=='Y');         fp.close(); } 
 void display_spb(char n[]) {         cout<<" BOOK DETAILS ";         int flag=0;         fp.open("book.dat",ios::in);         while(fp.read((char*)&bk,sizeof(book)))         {                 if(strcmpi(bk.retbno(),n)==0)                 {                         bk.show_book();                         flag=1;                 }         }                  fp.close();         if(flag==0)                 cout<<"  Book does not exist";         getch(); }  void display_sps(char n[]) {         cout<<" STUDENT DETAILS ";         int flag=0;         fp.open("student.dat",ios::in);         while(fp.read((char*)&st,sizeof(student)))         {                 if((strcmpi(st.retadmno(),n)==0))                 {                         st.show_student();                         flag=1;                 }         }                  fp.close();         if(flag==0)                 cout<<"  Student does not exist";         getch(); } 
 void modify_book() {         char n[6];         int found=0;         clrscr();         cout<<"  	MODIFY BOOK REOCORD.... ";         cout<<"  	Enter The book no. of The book";         cin>>n;         fp.open("book.dat",ios::in|ios::out);         while(fp.read((char*)&bk,sizeof(book)) && found==0)         {                 if(strcmpi(bk.retbno(),n)==0)                 {                         bk.show_book();                         cout<<" Enter The New Details of book"<<endl;                         bk.modify_book();                         int pos=-1*sizeof(bk);                         fp.seekp(pos,ios::cur);                         fp.write((char*)&bk,sizeof(book));                         cout<<"  	 Record Updated";                         found=1;                 }         }          fp.close();         if(found==0)                 cout<<"   Record Not Found ";         getch(); }   void modify_student() {         char n[6];         int found=0;         clrscr();         cout<<"  	MODIFY STUDENT RECORD... ";         cout<<"  	Enter The admission no. of The student";         cin>>n;         fp.open("student.dat",ios::in|ios::out);         while(fp.read((char*)&st,sizeof(student)) && found==0)         {                 if(strcmpi(st.retadmno(),n)==0)                 {                         st.show_student();                         cout<<" Enter The New Details of student"<<endl;                         st.modify_student();                         int pos=-1*sizeof(st);                         fp.seekp(pos,ios::cur);                         fp.write((char*)&st,sizeof(student));                         cout<<"  	 Record Updated";                         found=1;                 }         }                  fp.close();         if(found==0)                 cout<<"   Record Not Found ";         getch(); } 
 void delete_student() {         char n[6];         int flag=0;              clrscr();         cout<<"   	DELETE STUDENT...";         cout<<"  Enter The admission no. of the Student You Want To Delete : ";         cin>>n;         fp.open("student.dat",ios::in|ios::out);         fstream fp2;         fp2.open("Temp.dat",ios::out);         fp.seekg(0,ios::beg);         while(fp.read((char*)&st,sizeof(student)))         {                 if(strcmpi(st.retadmno(),n)!=0)                         fp2.write((char*)&st,sizeof(student));                 else                         flag=1;         }                  fp2.close();         fp.close();         remove("student.dat");         rename("Temp.dat","student.dat");         if(flag==1)                 cout<<"  	Record Deleted ..";         else                 cout<<"  Record not found";         getch(); }   void delete_book() {         char n[6];         clrscr();         cout<<"   	DELETE BOOK ...";         cout<<"  Enter The Book no. of the Book You Want To Delete : ";         cin>>n;         fp.open("book.dat",ios::in|ios::out);         fstream fp2;         fp2.open("Temp.dat",ios::out);         fp.seekg(0,ios::beg);         while(fp.read((char*)&bk,sizeof(book)))         {                 if(strcmpi(bk.retbno(),n)!=0)                   {                         fp2.write((char*)&bk,sizeof(book));                 }         }                  fp2.close();         fp.close();         remove("book.dat");         rename("Temp.dat","book.dat");         cout<<"  	Record Deleted ..";         getch(); } 

Explanation / Answer

I assume you are trying to compile on Linux. <process.h> is a windows only header and I believe <conio.h> is as well. There may be Linux equivilants if you could post what functions you are trying to use. I usually use the following for cross compatability over windows and linux.

Code:

It helps with somestandard ANSI functions that are defined in different headers on Linux than they are on Windows.

Use any one of the following syntax to compile the program called demo.c:

OR

OR

How do I compile a C++ program that uses Xlib graphics functions?

The syntax is as follows when need pass the -lX11 option with gcc to link with the Xlib libraries:
g++ fireworks.C -o executable -lX11

  cc program-source-code.c -o executable-file-name  

OR

  gcc program-source-code.c -o executable-file-name  

OR

  ## assuming that executable-file-name.c exists ##  make executable-file-name  

How do I compile a C++ program that uses Xlib graphics functions?

The syntax is as follows when need pass the -lX11 option with gcc to link with the Xlib libraries:
g++ fireworks.C -o executable -lX11

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote