Are default enum values in C the same for all compilers?

前端 未结 4 1033
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 20:34

When declaring an enum as shown below, do all C compilers set the default values as x=0, y=1, and z=2 on both Linux and Windows system

4条回答
  •  爱一瞬间的悲伤
    2020-12-04 21:16

    Yes. Unless you specify otherwise in the definition of the enumeration, the initial enumerator always has the value zero and the value of each subsequent enumerator is one greater than the previous enumerator.

提交回复
热议问题