From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,4b604acc3b9aa7bf X-Google-Attributes: gid1164f8,public From: Duane Smith Subject: Re: DEC C Weirdness Date: 1996/07/16 Message-ID: <31EBB897.4429D897@zko.dec.com>#1/1 X-Deja-AN: 168532066 references: to: "James L. Heid" cc: d_smith, "quarry::mario" content-type: text/plain; charset=us-ascii organization: hndymn_usr$:[d_smith]/.organization mime-version: 1.0 newsgroups: comp.sys.dec x-mailer: Mozilla 2.02b1 (X11; I; DEC 3000 Model 400 ) 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 )