Xref: utzoo comp.lang.c:37095 comp.software-eng:5063 Path: utzoo!attcan!uunet!decwrl!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!ucsd!telesoft!rlk From: rlk@telesoft.com (Bob Kitzberger @sation) Newsgroups: comp.lang.c,comp.software-eng Subject: Re: Source File Organization Message-ID: <1208@telesoft.com> Date: 28 Feb 91 02:45:10 GMT References: <1991Feb26.045242.23453@rfengr.com> Organization: TeleSoft, San Diego, CA. Lines: 33 Rick Farris writes: > typedef enum { A, B, C, D } CMD; > > and a corresponding array of ascii representations : > > char ltrs[] = { 'A', 'B', 'C', 'D' }; Yes, you asked for a C solution, but since this was cross-posted to comp.software-eng I thought I'd point out Ada's solution to this. The example below specifies a type 'color', and a call to a language-defined attribute of this prefix, 'IMAGE. with text_io; procedure foo is type color is (red, green, blue ); my_color : color := green; begin text_io.put_line( color'image(my_color) ); end foo; All enumerated types have a corresponding 'IMAGE attribute, which implies that an ASCII (or EBCDIC ;-) representation of each enumerated value be present at execution time. These image tables may be supressed at compile time. .Bob. -- Bob Kitzberger Internet : rlk@telesoft.com TeleSoft uucp : ...!ucsd.ucsd.edu!telesoft!rlk 5959 Cornerstone Court West, San Diego, CA 92121-9891 (619) 457-2700 x163 ------------------------------------------------------------------------------ "Wretches, utter wretches, keep your hands from beans!" -- Empedocles