Somewhere I've read that integer constant expressions consists integer constants such as:
(5 + 5) //integer constant expression
That was the only example I have seen.
Now, from standard which says:
(C99 6.6/6) An integer constant expression shall have integer type
and shall only have operands that are integer constants, enumeration
constants, character constants, sizeof expressions whose results are
integer constants, and floating constants that are the immediate
operands of casts. Cast operators in an integer constant expression
shall only convert arithmetic types to integer types, except as part
of an operand to the sizeof operator.
So, are all these integer expressions below if I'm right?
int i; float f = 3.14f;
i = 42;
i = f;
i = (int)(5/3.14f);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…