Xref: utzoo comp.lang.c:37226 comp.software-eng:5096 Path: utzoo!news-server.csri.toronto.edu!rpi!masscomp!ocpt!bigguy!dave From: dave@bigguy.ocpt.ccur.com (David F. Carlson) Newsgroups: comp.lang.c,comp.software-eng Subject: Re: Source File Organization Summary: enums have power Message-ID: <1991Mar18.165208.25163@bigguy.ocpt.ccur.com> Date: 18 Mar 91 16:52:08 GMT References: <1991Feb26.045242.23453@rfengr.com> <1208@telesoft.com> Organization: Concurrent Computer Corp. Fairport NY Lines: 28 > Rick Farris writes: > > > typedef enum { A, B, C, D } CMD; > > > > and a corresponding array of ascii representations : > > > > char ltrs[] = { 'A', 'B', 'C', 'D' }; > I would usually overload the operation for this using the initialization property of enum types and the fact that they are defined to hold an integer: typedef enum { A = (int) 'A', B = (int) 'B', C = (int) 'C', D = (int) 'D'} CMD; or if lexically ASCII is assumed, typedef enum { A = (int) 'A', B, C, D } CMD; Since B, C and D will be sequential, they will be correctly initialized. Or is that cheating? :-) -- David F. Carlson, Concurrent Computer Co. dave@bigguy.ocpt.ccur.com Fairport, NY "The faster I go, the behinder I get." --Lewis Carroll