Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utastro.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!floyd!cmcl2!seismo!ut-sally!utastro!nather From: nather@utastro.UUCP (Ed Nather) Newsgroups: net.unix-wizards Subject: Re: getc() != EOF Message-ID: <85@utastro.UUCP> Date: Sun, 10-Jun-84 14:42:45 EDT Article-I.D.: utastro.85 Posted: Sun Jun 10 14:42:45 1984 Date-Received: Tue, 12-Jun-84 00:48:04 EDT References: <616@hou3c.UUCP> Organization: UTexas Astronomy Dept., Austin, Texas Lines: 34 [] >Re the following code: > char c; > while ((c = getc(file)) != EOF); > >The issue is whether the value returned from the assignment operator >should be the value of the left or of the right hand side of the as- >signment. C defines the value to be the value of the left hand side >of the assignment. > >I contend that this decision was a mistake. > > Kenneth Almquist I disagree. In my view, the parentheses indicate quite clearly the sequence of operations expected: 1. Call getc with the argument "file". 2. Store the result into the variable location called "c". 3. Compare that value with the value of "EOF". The "truncate and store" operation precedes the comparison, and I would be thoroughly confused if the sequence shown gave a different result from the (unfolded) sequence c = getc(file); if(c != EOF) ... -- Ed Nather {allegra,ihnp4}!{ut-sally,noao}!utastro!nather Astronomy Dept., U. of Texas, Austin