Optimal way to perform a shift operation on an array

前端 未结 6 1465
醉酒成梦
醉酒成梦 2021-02-20 08:00

Suppose I have an array

unsigned char arr[]= {0,1,2,3,4,5,6,7,8,9};

Is there a way to perform shift operation on them besides just copying them

6条回答
  •  死守一世寂寞
    2021-02-20 08:40

    If you're the only person with a pointer to the array, just increment the pointer and decrement the length.

    Just remember to keep the original pointer around for when you free it.

提交回复
热议问题