Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!homxb!mtuxo!mtune!codas!killer!tness1!petro!jrb From: jrb@petro.UUCP (Jon Boede) Newsgroups: comp.lang.c Subject: Re: C arrays of strings Message-ID: <472@petro.UUCP> Date: Wed, 18-Nov-87 11:33:36 EST Article-I.D.: petro.472 Posted: Wed Nov 18 11:33:36 1987 Date-Received: Sun, 22-Nov-87 09:16:34 EST References: <3157@rosevax.Rosemount.COM> Sender: news@petro.UUCP Reply-To: jrb@petro.UUCP (Jon Boede) Organization: G.M. Andreen & Associates, Inc. San Antonio, Texas Lines: 28 Keywords: C Summary: An array of 12 pointers to chars I'm probably one of about 50 zillion people who are going to respond to this, but I rolled my 20-sided die and it came up 6 ;-) In article <3157@rosevax.Rosemount.COM> richw@rosevax.Rosemount.COM (Rich Wagenknecht) writes: >Could someone explain the following declaration in english and >give an example of how to use it? I believe I can use this declaration >but cannot explain how is works. What I'm after is simply an array of >character strings. > > char *str[12]; "Str is an array of twelve pointers to characters, effectively an array of a dozen strings." You can use str as a "char *str" but with an index. For example, you could initialize it with the months of the year... int the_month; static char *str[12] = { "January", "February", ... }; printf("It's the month of %s\n",str[the_month]); Jon -- Jon Boede ...!{gatech,ihnp4,ssbn,swrinde,tness1,utanes}!petro!jrb 512/599-1847 2555 N.E. Loop 410, #1403, 78217 "People who are incapable of making decisions are the ones who hit those barrels at freeway exits."