query related to array and pointer
is this implementation correct
Following function Rotate is for rotating datavalues in the array to the value as mentioned in shift.
shift can be + ve and -ve
+ve shift means element at 0 moves to 'shift' position. For eg. if shift is 45 then element at 0 moves to 45 th position and hence complete rearragned like this
Code:
void Rotate(float *arr, int shift)
{
float tmp[4096];
// If shift is more than the size, restrict it to the size
if(shift > 4095)
shift = 4095;
for(int i=shift; i<4096; i++)
{
tmp[i] = arr[i-shift];
}
for(i=0; i<shift; i++) // if (shift > 0) clear wwrot shift
{
tmp[i] = 0;
}
for(i=0; i<4096; i++)
{
arr[i] = tmp[i];
}
}