| || |
Array Index Increments Variable
I am using an array, item, and I want to refer to something one past the midpoint, with the variable for midpoint being mid. I tried doing item[mid++] or item[mid+1], but that also increments the mid variable. Any ideas?
Re: Array Index Increments Variable
I would think the item[mid + 1] option would give the desired result (and should not change the value of mid). If ++ works like it does in most other languages, then item[mid++] should return the save value as item[mid] would, but the value of mid would then be incremented by 1. If all else fails, just do...
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">mid_next = mid + 1;
something = item[mid_next];</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">
[i]...Sound trumpets! Every trumpet in the host! / Sixty thousand, on these words, sound, so high the mountains sound, and the valleys resound.</i] (The Song of Roland)