I have an array of sockets (pfd[nfd].fd). I also have an array of pointers (event_tracking* track[10]). If there comes a point in my code where I try and receive data from a socket that is closed I would like to remove that array element in both arrays and then shift the arrays to fill the empty spot.
for(j=1; j<nfd; j++) {
if(pfd[j].revents&POLLIN) {
char* p = track.receive_datagram();
if (p == 0) {
delete track[j-1];
//Delete element in pfd[nfd].fd
//Reorder elements of track array
//Reorder elements of pfd array
}
}
}
I know you can call the delete operator to call the destructor for track but I'm not sure how to reorder the elements in the array now that one is missing? Or how to delete and reorder the pfd array?
Any help would be appreciated! I can't find any examples of deleting and reordering arrays in my text.