0

How to convert the enum below from int to string?

enum class EUserState :uint8
{
    Offline,
    Online,
    Busy,
    Away,
    Snooze,
    LookingToTrade,
    LookingToPlay, 
};
EUserState temp=EUserState::Online;

How to convert temp to a string without using a string array or something repeatly.
I don't want to make it cockamamie.
Trying to find a automatic change?
Can anyone help? :)

  • There are very few "automatic" things in C++, that the language will do for you. This isn't one of them. You must do all the work yourself. Using in array, or perhaps an external script that reads a YAML or XML enum definition and converts it to an enum declaration and code that maps it to a string. – Sam Varshavchik Dec 14 '21 at 01:54
  • Check out [this](https://stackoverflow.com/questions/28828957/enum-to-string-in-modern-c11-c14-c17-and-future-c20) – simondvt Dec 14 '21 at 01:54
  • More links https://stackoverflow.com/questions/5093460/how-to-convert-an-enum-type-variable-to-a-string?noredirect=1&lq=1#comment32807088_5093460 (...) – user202729 Dec 14 '21 at 01:59
  • I don't think there's any "automatic change"! – Shuvo Sarker Dec 14 '21 at 01:59

0 Answers0