C++ function putting garbage into array -


There is a problem with this function, until the sum works all right, instead of the new inset, the memory address in the array Includes:

  Bull reserve seat (string name [], int reservation [] [2], int and notepaper) {Bull reserve = Falls; String searchname; Int row, seat, lawful, valid seat; Cout & lt; & Lt; "Please enter the reservation name:"; Gateline (pin, search name); Cout & lt; & Lt; "Please enter a line #:"; Cin & gt; & Gt; Line; Cout & lt; & Lt; "Please enter a seat #:"; Cin & gt; & Gt; Seat; cin.ignore (80, '\ n'); Valid Rau = Valid Curt (line, '10'); Validate = valid; seat (seat, '3'); (Int CTR = 0; CTR & lt; nopassengers; ctr ++) {if (seat == reservation [CTR] [1] & amp; RO == reservation [CTR] [0]) {break; } And {reserved = true; NoPassengers ++; Name [noPassengers] = searchName; Reservation [noPassengers] [0] = Row; Reservation [noPassengers] [1] = seat; }} Returns Reserved; }   

The function is called by main () via:

  (if reserved seat (name, reservation, Sender)) cout & lt; & Lt; "Reservations made"; And cout & lt; & Lt; "No reservation made"; Cout & lt; & Lt; Endl;   

The size of all arrays is 12, according to the request only valid entries in the Seat Function are 4 entries:

  int valid seat (int and call, int max ) {While (Call & gt; Max || Color & lt; 0) {cout & lt; & Lt; "Sorry, that's within an invalid category." & Lt; & Lt; Andal & lt; & Lt; "Again: "; Cin & gt; & Gt; col; } Return Colonel; }   

Any passenger is determined by the load found here:

  int loadArrays (ifstream & wings, string name [], int reservation [2]]} {int row = 0; {Getline (feather, name [row]) for (; line & lt; size; line ++); If (wings ()) break; (Int col = 0; col & lt; 2; col ++) {wings & gt; & Gt; Reservation [row] [col]; } fin.ignore (80, '\ n'); } Return line; }    

verifySat (line, '10 '); is a mistake '10' A multi-byte character will be fixed, which I'm sure is what you want.

Update: Please valid it (line, 10) , and after validation row (seat, 3) .

Apart from this, it is also possible that reservation [noPassengers] or name [noPassengers] is beyond the limit of memory allocated by you, we Can not tell based on the code you showed.

Please update this post to show your post to show that you allocated memory for reservation and name before calling this function We do. (Show codes, do not describe code).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -