Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!pt.cs.cmu.edu!cadre!pitt!darth!gary From: gary@darth.UUCP (Gary Wisniewski) Newsgroups: net.lang.c Subject: Re: C Coding Question Message-ID: <138@darth.UUCP> Date: Tue, 12-Aug-86 11:32:47 EDT Article-I.D.: darth.138 Posted: Tue Aug 12 11:32:47 1986 Date-Received: Sun, 17-Aug-86 06:11:19 EDT References: <248@killer.UUCP> Reply-To: gary@darth.UUCP (Gary Wisniewski) Followup-To: net.lang.c Organization: Darth Software, Allison Park, Pa. 15101 Lines: 34 Keywords: Attention all nit-pickers... Distribution: In article <248@killer.UUCP> tad@killer.UUCP writes: >Hey, everybody, I discovered a "new" (new to me) way of coding such static >things as descriptions, helps, and the like. It goes like this: > [At this point, the author includes code which builds a table of char *'s which are preinitialized and terminated with a NULL ptr, then builds a function say(char *) which prints out the entire list.] > >Here's the question: Should help and description be declared char *help[] >or char **help? Should say() be declared void, or is there some sort of >error checking I should implement? Are there any other suggestions or >comments? How about any other neat "tricks" anyone has discovered lately? > > Tad >-- >Tad Marko The technique you've discovered is actually a small part of a much more general facility in C. For more interesting ideas about ways to create complex pre-initialized structures and tables, look at K&R, page 124. As far as your question about "char *help[]" and "char **help": the two forms are IDENTICAL to virtually every C compiler (that's worth its salt). Arrays in C are merely special cases of pointers. In other words, both forms are correct. Section 5.3 of K&R explain this more fully. Happy C-ing. Gary J. Wisniewski Pittsburgh, PA Usenet: {allegra, bellcore, cadre}!pitt!darth!gary