int main()
{
enum Days{Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday};
Days TheDay;
int j = 0;
printf("Please enter the day of the week (0 to 6)\n");
scanf("%d",&j);
TheDay = Days(j);
//how to PRINT THE VALUES stored in TheDay
printf("%s",TheDay); // isnt working
return 0;
}
Run Code Online (Sandbox Code Playgroud) 如果我有这样的枚举
enum Errors
{ErrorA=0, ErrorB, ErrorC};
Run Code Online (Sandbox Code Playgroud)
然后我想打印到控制台
Errors anError = ErrorA;
cout<<anError;/// 0 will be printed
Run Code Online (Sandbox Code Playgroud)
但我想要的是文本"ErrorA",我可以不使用if/switch吗?
你有什么解决方案?