>
> what my question is is how do i delete a entry from an array, like set
> array[x] to 0, then delete any values with 0, and fix the array, like:
> say I have an array[10] =
> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }
>
> then I set array[4] to 0:
> { 1, 2, 3, 4, 0, 6, 7, 8, 9, 0 }
>
> then I update the array, what I want it to read now is this:
> { 1, 2, 3, 4, 6, 7, 8, 9, 0, 0 }
>
>
> I'm having trouble figuring out a for loop that will do this for me, so
> any help would be VERY appreciated...
Could you be more specific? Deleting entries in an array can mean
different things. For the example you gave the following would
work:
unsigned int *i;
unsigned int *ii;
for (i = ii = array; i != (array + 10); ++i, ++ii) {
while ((*i == 0) && (++i != (array + 9)))
;
*ii = *i;
}
while (++ii != (array + 10))
*ii = 0;
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST