Can someone explain how to append an element to an array in C programming?

后端 未结 6 523
轻奢々
轻奢々 2021-02-05 03:55

If I want to append a number to an array initialized to int, how can I do that?

int arr[10] = {0, 5, 3, 64};
arr[] += 5; //Is this it?, it\'s not working for me.         


        
6条回答
  •  执念已碎
    2021-02-05 04:18

    You can have a counter (freePosition), which will track the next free place in an array of size n.

提交回复
热议问题