Removing elements from an array in C

后端 未结 6 889
你的背包
你的背包 2020-12-02 23:37

I just have a simple question about arrays in C

What\'s the best way to remove elements from an array and in the process make the array smaller.

i.e the ar

6条回答
  •  悲&欢浪女
    2020-12-02 23:44

    I usually do this and works always.


    /try this/

    for (i = res; i < *size-1; i++) { 
    
        arrb[i] = arrb[i + 1];
    }
    
    *size = *size - 1; /*in some ides size -- could give problems*/
    

提交回复
热议问题