### Where did it go?

Trying to understand this.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051`` ``````//Get number cin >> dPhone; //Show information at index and "delete an entry." while( index < size && !found ) { if(tele[index].phone.compare(dPhone)== 0) { cout << "--Deleting--" << endl; cout << endl; cout << tele[index].lname << endl; cout << tele[index].fname << endl; cout << tele[index].streetAdd << endl; cout << tele[index].cityStateZ << endl; cout << tele[index].phone << endl; cout << endl; //To "remove" element. //This is just to see what it is before for(int i = 0; i < size; i++) { cout << tele[i].lname << endl; cout << tele[i].fname << endl; cout << tele[i].streetAdd << endl; cout << tele[i].cityStateZ << endl; cout << tele[i].phone << endl; } //The mystery --size; tele[index] = tele[size]; //To see after for(int j= 0; j < index; j++) { cout << endl; cout << tele[j].lname << endl; cout << tele[j].fname << endl; cout << tele[j].streetAdd << endl; cout << tele[j].cityStateZ << endl; cout << tele[j].phone << endl; } found = true; } else if(!found) index++; }``````

The original array has smith,lauren, cory,walter, jack. When I do the cout before the part I don't understand I get smith, lauren, cory ,walter,jack.Now say I delete walter. When I do the cout after I get ..smith lauren, jack.

If you notice that is 3. When I display in a different function. I get jack, lauren, cory, smith (this is corret)

The code works but I"m trying to understand how it is working. What is happening in the middle part. And how is it correct at the end//?
thanks

edit;;;;i made the second loop <size and I see everything. But still dont understand
Last edited on
Topic archived. No new replies allowed.