www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/10/23:16:00

From: Eamon Walsh <ewalsh AT lan DOT tjhsst DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Hi
Date: Tue, 10 Feb 1998 22:55:10 -0500
Organization: Erol's Internet Services
Lines: 21
Message-ID: <34E1211E.8F9@lan.tjhsst.edu>
References: <34E03363 DOT 1A28E21C AT student DOT unsw DOT edu DOT au>
Reply-To: ewalsh AT lan DOT tjhsst DOT edu
NNTP-Posting-Host: 207-172-57-234.s234.tnt2.ann.erols.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Charbel Sadaka wrote:
> 
>  Hi ,
> I'm Charbel (or just Charlie if you prefer), and would really appreciate
> it if you could solve this simple problem I have.
> 
> I've downloaded the c compiler from delorie.com for win95(ieDOS)and have
> no problems with it except that I've tried writing a simple program to
> read from the stdin and count the number of characters in it using the
> following code:
>      while (ch=getchar( ) != EOF) {
>                  count++
>     }

	Besides the fact that EOF is control Z in dos, not control D, this code
won't work because the != operator has higher precedence than the =
(assignment) operator.  So what the code in the while parentheses says
is "if you entered EOF then store false in ch, else store true".  You
can fix this using parentheses: (ch = getchar()) != EOF)

-Eamon Walsh

- Raw text -


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