Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!dkuug!resam!andrew From: andrew@resam.dk (Leif Andrew Rump) Newsgroups: comp.lang.c Subject: Is this bad programming? Summary: Using #define while defining arrays! Keywords: #define array definition Message-ID: <1990Aug8.100614.1223@resam.dk> Date: 8 Aug 90 10:06:14 GMT Organization: RESAM Project Office, SAS, CPHML-V Lines: 45 Well I know it doesn't look smashing but instead of writing: #define FILE_FOOTER_ERROR 1 #define DRAW_FOOTER_ERROR 2 #define GRAP_FOOTER_ERROR 3 #define BASE_FRAME_CREATE_ERROR 4 char errortext[][40] = { /*00*/ "234567890123456789012345678901234567890", /*01*/ "File footer error", /*02*/ "Draw footer error", /*03*/ "Grap footer error", /*04*/ "Base_frame creation error", } which I may write wrong because I forget a line or add a line. This is allowed by my compiler (I figure the preprocessor removes it and performs symbol substitution before giving it to the compiler) and I know that all the lines are there! char errortext[][40] = { "234567890123456789012345678901234567890", #define FILE_FOOTER_ERROR 1 "File footer error", #define DRAW_FOOTER_ERROR 2 "Draw footer error", #define GRAP_FOOTER_ERROR 3 "Grap footer error", #define BASE_FRAME_CREATE_ERROR 4 "Base_frame creation error", } I am a pascal-programmer (aha, that is why :-) ) in my real life and I could also use union/enumerated types. Leif Andrew Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark UUCP: andrew@ambra.dk, phone: +45 39 27 11 77 / Currently at Scandinavian Airline Systems =======/ UUCP: andrew@resam.dk, phone: +45 32 32 22 79 \ SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark > > Read oe as: o / (slash) and OE as O / (slash) < <