delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/07/07/06:30:43

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Esa A E Peuha <esa DOT peuha AT helsinki DOT fi>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: pointers in Strucrure assignment problem
Date: 07 Jul 2005 13:25:39 +0300
Organization: University of Helsinki
Lines: 29
Message-ID: <86ppstuoqu4.fsf@sirppi.helsinki.fi>
References: <1120713425 DOT 526371 DOT 222910 AT g47g2000cwa DOT googlegroups DOT com> <TG4ze.17390$pa3 DOT 15032 AT newsread2 DOT news DOT atl DOT earthlink DOT net> <42CCF54B DOT 4DBA817A AT yahoo DOT com>
NNTP-Posting-Host: sirppi.helsinki.fi
X-Trace: oravannahka.helsinki.fi 1120731941 6967 128.214.205.27 (7 Jul 2005 10:25:41 GMT)
X-Complaints-To: abuse AT helsinki DOT fi
NNTP-Posting-Date: 7 Jul 2005 10:25:41 GMT
X-Newsreader: Gnus v5.6.43/Emacs 19.34
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

CBFalconer <cbfalconer AT yahoo DOT com> writes:

> >     *LD[i].LinePtr = 0;
> 
> How does that bind?  I am always deeply suspicious of C's
> hierarchy,

"Hierarchy"?  Oh, you mean operator precedence.  In this case it's
simple: unary from right always has higher precedence than unary from
left.

> so I would (in self defense) write:
> 
>          *(LD[i].LinePtr) = '\0';

Why?  Even if the compiler gets the precedence wrong (which is
unlikely), it would then have to dereference a struct.  I don't think
that any compiler has ever been able to do that without an error.

> or even
>          *((LD[i]).LinePtr) = '\0'; /* for total paranoia */

What, you think the compiler might otherwise parse it as LD([i].LinePtr)
and not give an error? :-)

-- 
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019