SPUG: C question ;)
Pommert, Daniel
Daniel.Pommert at verizonwireless.com
Mon Mar 11 11:23:31 CST 2002
Sorry. I didn't read the previous respondant's comments carefully enough.
He, too was only concerned about the last one.
-- Daniel
-----Original Message-----
From: Pommert, Daniel [mailto:Daniel.Pommert at verizonwireless.com]
Sent: Monday, March 11, 2002 8:20 AM
To: 'sthoenna at efn.org'; spug-list at pm.org
Subject: RE: SPUG: C question ;)
No. The first three will work irrespective of the size of the pointed to
object. (The fourth may work also; I'm not sure.) Look at the C standard
section 6.3.2.1. In the example it explicitly says, "Then i is adjusted
according to the type of x. which conceptually entails multiplying i by the
size of the object to which the pointer points, ..."
-- Daniel Pommert
-----Original Message-----
From: sthoenna at efn.org [mailto:sthoenna at efn.org]
Sent: Sunday, March 10, 2002 10:54 PM
To: spug-list at pm.org
Subject: Re: SPUG: C question ;)
In article <20020310212822.A54051 at sabami.seaslug.org>,
Scott Blachowicz <scott at mail.dsab.rresearch.com> wrote:
> /* All of these should be equivalent (unless I'm remembering wrong). */
> (ptr+499)->a = 0;
> (*(ptr+499)).a = 0;
> ptr[499].a = 0;
> 499[ptr].a = 0; /* !! */
Last one only works if sizeof *ptr == 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list