0
Array shift
If I want to delete array element by shifting to left from some index, does it matter if I happen to reference past array bounds? Like, when deleting last element. Heres what I mean: if (nelem > index) { nelem--; memcpy(&data[index], &data[index + 1], sizeof (MyData) * (nelem - index)); }
4 Answers
+ 1
Thanks!
0
Hmm, wait, how about if I check if element to be removed is last one and then just decrease element count? Otherwise do as in 1st post.