shift positions inside of an array?
#2

A simple loop.

Код:
for(new i = sizeof(array) - 1; i > 0; i --)
{
array[i] = array[i - 1];
}

array[0] = new_value;
Assuming an array size of 5, it first moves index 3 to 4, then 2 to 3, then 1 to 2 and last 0 to 1.
After that overwrite index 0 with the new value.
Reply


Messages In This Thread
shift positions inside of an array? - by wallee - 20.09.2018, 18:32
Re: shift positions inside of an array? - by NaS - 20.09.2018, 19:33
Re: shift positions inside of an array? - by wallee - 20.09.2018, 23:57

Forum Jump:


Users browsing this thread: 1 Guest(s)