Remove an array element and shift the remaining ones

前端 未结 8 743
灰色年华
灰色年华 2020-11-29 01:09

How do I remove an element of an array and shift the remaining elements down. So, if I have an array,

array[]={1,2,3,4,5} 

and want to del

8条回答
  •  孤街浪徒
    2020-11-29 01:31

    If you are most concerned about code size and/or performance (also for WCET analysis, if you need one), I think this is probably going to be one of the more transparent solutions (for finding and removing elements):

    unsigned int l=0, removed=0;
    
    for( unsigned int i=0; i

提交回复
热议问题