1.段錯(cuò)誤(吐核)
使用for語(yǔ)句循環(huán)輸出enum內(nèi)枚舉元素時(shí),
#include <stdio.h>
enum STATE
{
LOADING,
OK,
FAI,
ERROR
}state;
void main()
{
for(state=LOADING;state<=ERROR;state++)
{
printf("The state now is:%d\n",state);//因?yàn)檫@里%d寫成%s導(dǎo)致報(bào)如上錯(cuò)誤
if(state>ERROR)
state=LOADING;
}
}
可參見博客文https://blog.csdn.net/qq_42351880/article/details/85332621