Home > Back-end >  C library system input information is not successful
C library system input information is not successful

Time:11-19

The input information is not successful, how to change?
#include
#include
#include
#include
#include
using namespace std;
# define BOOK 100
//book information
Struct the Book
{int book_no.//book number
Char name [30].//title
Char author [20].//the author
Char press [20].//press
Char date [15].//date of publication: YYYY - MM - DD
Char kind [15].//book category
Double price.//book price
Int total;//number of books
};
//book
The class book
{
Private:
The Book bo_array [Book];//books array
Int booknum;//the current record books
Public:
The book ();
~ the book ();
Void menu ();
Int get_booknum ();//get the current record books
Void input ();
Void the search ();//find
void update();
Void the show ();
Void delete_ ();
Void the load_file ();
Void save_file ();
};
Book: the book ()
{
Booknum=0;
}
The book: : ~ the book ()
{
}
Int the book: : get_booknum ()
{
Return booknum;
}
Void book: : menu ()
{
Int choice;
system("cls");
Cout<& lt;" Books management system management system "& lt; Cout<& lt;" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "& lt; Cout<& lt;" "\ t \ t1 entry books information & lt; Cout<& lt;" Reading books information \ \ t t2. "& lt; Cout<& lt;" \ \ t t3. Query book information "& lt; Cout<& lt;" \ \ t t4. Modify the book information "& lt; Cout<& lt;" \ t \ t5. Delete the book information "& lt; Cout<& lt;" "\ t \ t6 exit system & lt; Cout<& lt;" Please select (1-6) : ";
Cin> Choice;
If (choice>=0 & amp; & Choice<7)
{
The switch (choice)
{
Case 1:
The input ();
break;
Case 2:
Show ();
break;
Case 3:
Search ().
break;
Case 4:
The update ();
break;
Case 5:
Delete_ ();
break;
Case 6:
Save_file ();
Cout<& lt;" Thank you for your use, the system has quit, bye!" system("pause");
The exit (0);
}
}
The else
{
Cout<& lt;" Input is wrong! Please input again!" }
}

Int main ()
{
The book book1.
While (1)
{
Book1. Menu ();
}

return 0;
}


Void book: : input ()
{
The Book boo;
Get_booknum ();
While (1)
{
system("cls");
Cout<& lt;" Please enter the below (add) book information: "& lt; Cout<& lt;" Please enter the book number, title, author, publishing house, publication date (0 exit) : "& lt; Cin> Boo. Book_no;
If (boo. Book_no==0)
return;
Cin> Boo. Book_no & gt;> Boo. Name> Boo. Author> Boo. Press> Boo. Date;
Cout<& lt;" Please enter the book category, book price (unit: yuan), number of books: "& lt; Cout<& lt;" (category: science and technology, language and literature, political economy, history, geography, ideology, art) "& lt; Cin> Boo. Kind> Boo. Price> Boo. Total;
Bo_array [booknum]=boo;
Booknum++;
}
}

Void book: the load_file ()
{
The Book boo;
Ifstream infile.
Get_booknum ();
Infile. Open (" bookfile. TXT ", the ios: : in);
if(! Infile)
{
Cout<& lt;" No data file bookfile. TXT!" ;
Sleep (3000);
Booknum=0;
return;
}
while(! Infile. Eof ())
{
Infile> Boo. Book_no & gt;> Boo. Name> Boo. Author> Boo. Press> Boo. Date> Boo. Kind> Boo. Price> Boo. Total;
If (infile)
{
Bo_array [booknum]=boo;
Booknum++;
}
The else
break;
}
Infile. Close ();
return;
}
Void book: : save_file ()
{
Ofstream outfile;
Get_booknum ();
Outfile. Open (" bookfile. TXT ", the ios: : out);
if(! Outfile)
{
Cout<& lt;" Unable to save data to a file bookfile. TXT in!" Sleep (3000);
return;
}
for(int i=0; I{
OutfileOutfile}
Outfile. Close ();
Cout<& lt;" Already will "& lt; Sleep(1000);
return;
}

Void book: the search ()
{
The Book boo;
Int bo_no;
Bool judge=0;
Cout<& lt;" Please input to query book number: "& lt; Cin> Bo_no;
Cout<& lt;" Results: "& lt; for(int i=0; I{
If (bo_array [I] book_no==bo_no)
{
Judge=1;
Cout<& lt;" Book number title authors publishing date book category book price collection quantity & lt;" Cout<& lt;" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "& lt; CoutCout}
}
If (judge==0)
{
Cout<& lt;" nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related