Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   C query (http://www.go4expert.com/forums/c-query-t7553/)

shyam_oec 26Nov2007 23:25

C query
i want to get the print of enumuration constants that has been defined in current enumeration in C language.how?

shabbir 26Nov2007 23:27

Re: C query
Moved to C-C++ forum.

Salem 27Nov2007 04:31

Re: C query
The short answer is "you can't", not in standard C.


enum colours { red, green, blue };
there is no quick and easy way of getting the system to print say "red".

One way is to define a lookup table, such as

struct {
  enum colours;
  char *word;
} table[] = {
  { red, "red" },
  { green, "green" },
  { blue, "blue" }

All times are GMT +5.5. The time now is 07:42.