The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Enum fun... by MrTrick 2005-05-11 17:54:19
I'm debugging a C++ application, where one of the parameters is an enum.
I want to print out the string representation of the parameter... what's the easiest/quickest/best way to do it in C++?

If it were Euphoria (a language I'm much more familiar with) I'd do it like this: (values changed to protect the innocent)

constant
ONE = 1,
TWO = 2,
PURPLE = 3,
FIVE = 4, 
GOLDFISH = 5
constant lookup = {"ONE", "TWO", "PURPLE", "FIVE", "GOLDFISH" } //(1-based arrays)

procedure printEnum(integer enum)
    printf(1, "Value is: %s\n, {lookup[enum]})
end procedure

[ Reply ]
  There's unfortunately no... by williamashbless2005-05-11 18:09:10
  One version of the C++ would look by ManiacJoe2005-05-11 18:09:52
  Thanks, Joe and Will by MrTrick2005-05-11 18:13:29

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)