Jack Klein wrote:
> On Thu, 8 May 2008 02:20:26 -0500 (CDT), Vickynathan
> <ragunath73@[EMAIL PROTECTED]
> wrote in comp.lang.c.moderated:
>
>> The following code snippet works. I wonder how ? ( this is a code for
>> microcontroller )
>>
>> void main (void){
>
> Before anyone else mentions it, since this is a free-standing
> implementation, void main() is not necessarily undefined behavior, and
> in fact is this particular implementation's normal entry point. In
> small embedded systems, there is nothing for main() to return to.
Yes, true and easy to miss.
<snip>
> In C, the expression symbol1 [symbol2] is always an indirection
> operation. The language requires that this be translated as follows:
>
> First, if symbol1 is an array name, it is converted to a pointer to
> its first element.
>
> After this conversion, or if symbol1 was a pointer to start with, the
> expression is converted to *(symbol1 + symbol2).
>
No, well partly true. symbol1[symbol2] always converts to *[symbol1 +
symbol2] and one or other of symbol1 and symbol2 will either be a
pointer or an expression implicitly convertible to a pointer. Weird
though it seems:
int array[4];
int i;
for(i=0; i<4; ++i){
i[array] = i;
]
works fine :)
--
Note that robinton.demon.co.uk addresses are no longer valid.
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|