我想将枚举变量声明为值.我怎样才能做到这一点?
例如:
public enum CardSuit {
SPADE(0), HEART(1), DIAMOND(2), CLUB(3);
}
Run Code Online (Sandbox Code Playgroud)
我可以这样声明:
CardSuit s = CardSuit.SPADE;
Run Code Online (Sandbox Code Playgroud)
我也想这样声明:
CardSuit s = 1;
Run Code Online (Sandbox Code Playgroud)
这样做的方法是什么?这甚至可能吗?
#include <stdio.h>
#include <string.h>
int main()
{
const char str[11]= "Hello World";
if(-1 > strlen(str)){
printf(str);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
This if condition should always return false. But here it's not.
But if I put strlen(str) value to another variable and compare with that, then it works as expected.
What I am missing here?
Is it compiler dependent or something?