When to use enums?

后端 未结 5 1097
长发绾君心
长发绾君心 2021-01-24 07:51

I\'m currently reading about enums in C. I understand how they work, but can\'t figure out situations where they could be useful. Can you give me some simple examples where the

5条回答
  •  醉话见心
    2021-01-24 08:14

    They're often used to group related values together:

    enum errorcode {
        EC_OK = 0,
        EC_NOMEMORY,
        EC_DISKSPACE,
        EC_CONNECTIONBROKE,
        EC_KEYBOARD,
        EC_PBCK
    };
    

提交回复
热议问题