Inventory Program in C. Need help on how to delete an item from inventory

前端 未结 1 385
栀梦
栀梦 2021-01-29 06:28

This is a program that holds inventory. The program displays a menu of options. Everything else works perfect except the delete an entry function. I do not know how to make it d

相关标签:
1条回答
  • Following your coding style, although it should improve:

    void remove_item(gaming entry[], int *size, int item) {
        memcpy(&entry[item], &entry[*size], sizeof(entry[0]));
        *size = *size - 1;
    }
    

    This code will override the desired entry (at index item) and decrease the last index (size) by one.

    0 讨论(0)
提交回复
热议问题