Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: Pointer ini...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 8 Topic 1096 of 1126
Post > Topic >>

Re: Pointer initialization and usage.

by Francis Glassborow <francis.glassborow@[EMAIL PROTECTED] > May 13, 2008 at 01:06 AM

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.
 




 8 Posts in Topic:
Pointer initialization and usage.
Vickynathan <ragunath7  2008-05-08 02:20:26 
Re: Pointer initialization and usage.
Francis Glassborow <fr  2008-05-09 17:33:03 
Re: Pointer initialization and usage.
Kenneth Brody <kenbrod  2008-05-09 17:33:05 
Re: Pointer initialization and usage.
Vickynathan <ragunath7  2008-05-13 01:06:11 
Re: Pointer initialization and usage.
=?ISO-8859-1?Q?Hans-Bernh  2008-05-09 17:33:09 
Re: Pointer initialization and usage.
Jack Klein <jackklein@  2008-05-09 17:33:14 
Re: Pointer initialization and usage.
Vickynathan <ragunath7  2008-05-13 01:06:17 
Re: Pointer initialization and usage.
Francis Glassborow <fr  2008-05-13 01:06:20 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 0:55:58 CDT 2008.