Denis Zaitsev wrote:
a) Formally, the code is correct. As p->what can never be < 0
according to its type.
I am assuming this is C code. C and C++ have different rules for enums.
This isn't strictly true. The C standard does not say that enums are
unsigned. It only says that they are equivalent
Consider the following example:
enum w {
//c=-1,
a,
b
};
whattodo (
char option
) {
static
struct todo {
enum w what;
char option;
} todos[]= {
{a,'a'},
{b,'b'},
{-1}
};
struct todo *p= todos;
do if (
(option