>There are (at least) two ways of defining an array of strings in C
>
>If the strings are unequal in length, you can define an array of pointers
>to the actual strings. This means that you have the strings in memory plus
>the array of pointers:
>
>char *p_to_string[] = { "long long string", "several", "short", "strings" } ;
>
>Or you can make all the strings equal length so that the compiler will
>actually make a two-dimensional array:
>
>char string_array[15][] = { { "15 char string"}, {"more string"}, {"etc" } } ;
>
>This generates an array of 15 character strings. Remember that stings are
>actually one byte longer than the character count to accommodate the null
>byte terminator.
>
>The compiler will warn you if any of the strings are too long. It will fill
>the short strings with nulls (0). I general, C allows only the last
>dimension to be automatic. All but the last must be defined in the source.
>
>Both methods have their place.
>
>Regards,
>
>Jim Ham
>
>
>
>At 02:08 PM 12/12/2000 , you wrote:
>> > const char menu[][] = {"item 1", "item 2", "item 3", "etc"};
>>
>>I don't know if this works in C18, but it is _not_ valid ANSI C.
>>
>>This _is_ valid ansi C:
>>
>>char const * const menu[] = { "item 1", "item 2", "item 3", "etc" };
>>
>>In this case, menu is an array of const pointers to const char.
>>
>>Each pointer points to one of the strings.
>>
>>This has the advantage of using less memory when the strings are of widely
>>varying length.
>>
>>Bob Ammerman
>>RAm Systems
>>(contract development of high performance, high function, low-level
>>software)
>>
>>--
>>
http://www.piclist.com hint: To leave the PICList
>>
EraseMEpiclist-unsubscribe-requestspam
spamBeGonemitvma.mit.edu
>
>>
>
>Jim Ham, Porcine Associates
>(650)326-2669 fax(650)326-1071
>"http://www.porcine.com"
>
>--
>
http://www.piclist.com hint: To leave the PICList
>
RemoveMEpiclist-unsubscribe-requestKILLspam
mitvma.mit.edu
>
>