Home > Back-end >  Vs run successful code running in vc6.0 have a bug
Vs run successful code running in vc6.0 have a bug

Time:09-16

#include
#include
#include
#include
#include
using namespace std;
Struct node {
String name;//title
String publication;//publication date
String Warehousing;//warehousing date
String press;
String actor;
} a, [100000].
int i=0;
String STR.
Int CMP (node x, node y) {//custom sorting way
Return x.p ublication & lt; Y.p ublication;
}
Void () {//input function in
Cout & lt; <"Please input the title" & lt; Getchar ();
Getline (cin, a [I] name);
Cout & lt; <"Please enter the date of publication (format: xx (year). Xx (month) (day) xx)" & lt; Getline (cin, a [I]. Publication);
Cout & lt; <"Please enter today's date (format: xx (year). Xx (month) (day) xx)" & lt; Getline (cin, [I] a Warehousing);
Cout & lt; <"Please enter the press & lt;" Getline (cin, [I] a press).
Cout & lt; <"Please enter the author" & lt; Getline (cin, a [i++]. Actor);
Cout & lt; <"Included complete" & lt; }
Void fin_d () {//find all inbound date book information
Cout & lt; <"Please enter the inbound date" & lt; Getchar ();
Getline (cin, STR);
Int ans=0;
For (int k=0; K & lt; i; K++) {
If (a [k]. Warehousing==STR) {
Cout & lt; Ans++;
}
}
Cout & lt; <"Search is complete, a total of search for" & lt; }
Void sor_t () {//ordering books are available according to the date of publication and display the results
Sort (a, a + I, CMP);
For (int k=0; K & lt; i; K++)
Cout & lt;
Cout & lt; <"Complete" & lt; }
Void change () {//modify book information
Cout & lt; <"Please input the title" & lt; Getchar ();
Getline (cin, STR);
For (int k=0; K & lt; i; K++) {
If (a [k]. Name==STR) {
Cout & lt; <"Please enter the date of publication" & lt; Getline (cin, a [I]. Publication);
Cout & lt; <"Please enter the inbound date" & lt; Getline (cin, [I] a Warehousing);
Cout & lt; <"Please enter the press & lt;" Getline (cin, [I] a press).
Cout & lt; <"Please enter the author" & lt; Getline (cin, a [i++]. Actor);
Cout & lt; <"Modify complete" & lt; break;
}
}
}
Void delet_e () {//delete the book information
Cout & lt; <"Please input the title" & lt; Getchar ();
Getline (cin, STR);
For (int k=0; K & lt; i; K++) {
If (a [k]. Name==STR) {
For (int j=k; J & lt; I - 1; J++) {
A [j]. Name=[j + 1). A name;
A [j]. Journal of publication=[j + 1). A publication;
A [j]. Journal of Warehousing=[j + 1] a Warehousing;
}
i--;
break;
}
}
}
Int main ()//software function choice: 1, the input information books; 2, the query book; 3, ordering books; 4, book information modification; 5, book information deleted;
0, exit the program{
Int order=1;
Do {
Cout & lt; <"Please select operation:" & lt; Cout & lt; <"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" & lt; Cout & lt; <"| | 1. Entry books information & lt; Cout & lt; <"| | 2. Query books" & lt; Cout & lt; <"| | 3. Ordering books" & lt; Cout & lt; <"Modify | | 4. Book information & lt; Cout & lt; <"Delete | | 5. Book information & lt; Cout & lt; <"| | 0. Exit program" & lt; Cout & lt; <"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" & lt; Cin & gt;> The order;
The switch (order) {
Case 1:
In ();
break;
Case 2:
Fin_d ();
break;
Case 3:
Sor_t ();
break;
Case 4:
Change ();
break;
Case 5:
Delet_e ();
break;
}
} while (order);
system("pause");
return 0;
}




Typing in book information, the meeting after input the author bugs (enter only Numbers do not), and then I deleted the entry of the author's code, found that the above situation will be shown after the input press,
  • Related