Gregg Woodcock <[EMAIL PROTECTED]> wrote:
> "Hildinger, Robert" <[EMAIL PROTECTED]> wrote:
>> Gregg's original code: static const char threeChars[] = {"123"};
>> Code from your reply: static const char threeChars[] = "123";
>>
>> Gregg's code may not be "perfect" C syntax, but it generates the same
>> exact code. The format of Gregg's definition for threeChars[] is
>> obviously NOT the essential problem.
>
> IT IS!!! I changed it to 'static const char *threeChars = "123";' and
> it works. The way I defined it initially DEFINITELY whacks out GCC
> compiler!!!
Your original code said "static const char threeChars[] = {"123"};",
which is an entirely different kind of thing.
The original one triggers the compiler bug Dave Lasker mentioned.
The other is entirely different and does not. A "GoodCoder" knows
the difference between these two instinctively; perhaps you want to
read the C FAQ or a book.
> My original definition is definitely wrong. It is defined as a 1
> dimensional array but is assigned a 2 dimensional array which has only 1
> element.
No, it's a single dimensional array. That initialisation is unorthodox
but not invalid. Here's what the C standard section on Initialization
has to say about this (C90 6.5.7; C99 6.7.8/11):
An array of character type may be initialized by a character
string literal, optionally enclosed in braces. [...]
John
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/