Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: Duane Smith <d_smith@zko.dec.com>
To: "James L. Heid" <heid_james@lanl.gov>
Cc: d_smith, "quarry::mario"
Subject: Re: DEC C Weirdness
Date: 1996/07/16	[thread overview]
Message-ID: <31EBB897.4429D897@zko.dec.com> (raw)
In-Reply-To: heid_james.67.00110427@lanl.gov


James L. Heid wrote:
> 
> This happened to me on OpenVMS VAX V6.1 running DEC C V5.0-003
> 
> There is a real application behind all this, but I will post the results of a
> test in the hope that someone can explain what is happening.
> 
> while ((c = fgetc(fp) != EOF)
>           putc(c, outfile);
> 

The precedence of "!=" is higher than that of "=" which means that
the evaluation order will be:

  while ( c = (fgetc(fp) != EOF) )

While the test for EOF will work okay, the assignment will be whatever
the inequality results are.  Try adding parens:

  while ( (c = fgetc(fp)) != EOF )



      reply	other threads:[~1996-07-16  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-12  4:00 DEC C Weirdness James L. Heid
1996-07-16  4:00 ` Duane Smith [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox