0

I have an enum which looks like this:

enum types
  {
    none,
    fire,
    water,
    ....
  };

and then

char buffer[4096];
cin >> buffer;

if (strcmp(buffer, "fire") == 0)
  type = fire;
... and so on

My question is, is there any better and easier way to convert from string to enum type?

P.S - my knowledge currently is at OOP.

Petar D.
  • 307
  • 1
  • 2
  • 18

0 Answers0