From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23453 invoked from network); 15 May 2020 20:19:01 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 15 May 2020 20:19:01 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id A85739C966; Sat, 16 May 2020 06:18:58 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 350909C677; Sat, 16 May 2020 06:18:43 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mxes.net header.i=@mxes.net header.b="Eow3eXWU"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 2EF699C677; Sat, 16 May 2020 06:18:41 +1000 (AEST) Received: from smtp-out-3.mxes.net (smtp-out-3.mxes.net [198.205.123.68]) by minnie.tuhs.org (Postfix) with ESMTPS id 15C1F9C668 for ; Sat, 16 May 2020 06:18:40 +1000 (AEST) Received: from Customer-MUA (mua.mxes.net [10.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTPSA id AA40775966; Fri, 15 May 2020 16:18:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mxes.net; s=mta; t=1589573918; bh=KUWc05VAcOT601su5Sz/HaU3qY8XhUU+8A5/DvCzHQU=; h=From:To:References:In-Reply-To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=Eow3eXWUyEIoZEQHdsOuISpZvo05KVL3YZS6+DZBDlxBHFXnTlVpIM7P3Y3AnfgiE wjiIRZcMaTVkV1xpPbo/ql9G1FQIJCBZe6Z/mSi4sne1PlR9qUakXdsHSR9T7tt7qZ poUzwvztXCttGN/5DXozkfMAbPPk873WgE0m+ugE= From: To: "'Clem Cole'" References: <202005141841.04EIfvEZ063529@tahoe.cs.Dartmouth.EDU> <20200515150122.GF30160@mcvoy.com> <014001d62af3$9cc209b0$d6461d10$@ronnatalie.com> In-Reply-To: Date: Fri, 15 May 2020 16:18:37 -0400 Message-ID: <019701d62af6$050344b0$0f09ce10$@ronnatalie.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0198_01D62AD4.7DF26800" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQG9ANzJLoUOr1G01nr91LNGaadNcQF8gWPuAmIHo/ECCfy4nAGrFaSRAdh6otABKJIg8KiHRKIw Content-Language: en-us X-Sent-To: Subject: Re: [TUHS] v7 K&R C X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 'The Eunuchs Hysterical Society' Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" This is a multipart message in MIME format. ------=_NextPart_000_0198_01D62AD4.7DF26800 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable EOF is defined to be -1. getchar() returns int, but c is a unsigned char, the value of (c =3D = getchar()) will be 255. This will never compare equal to -1. =20 =20 =20 Ron,=20 =20 Hmmm... getchar/getc are defined as returning int in the man page and C = is traditionally defined as an int in this code.. =20 On Fri, May 15, 2020 at 4:02 PM > wrote: Unfortunately, if c is char on a machine with unsigned chars, or = it=E2=80=99s of type unsigned char, the EOF will never be detected. =20 =20 =20 * while ((c =3D getchar()) !=3D EOF) if (c =3D=3D '\n') { /* entire = record is now there */ =20 ------=_NextPart_000_0198_01D62AD4.7DF26800 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

EOF is = defined to be -1.

getchar() returns = int, but c is a unsigned char, the value of (c =3D getchar()) will be = 255.=C2=A0=C2=A0=C2=A0 This will never compare equal to = -1.

 

 

 

Ron, 

=

 

Hmmm... getchar/getc are = defined as returning int in the man page and C is traditionally defined = as an int in this code..

 

On = Fri, May 15, 2020 at 4:02 PM <ron@ronnatalie.com> = wrote:

Unfortunatel= y, if c is char on a machine with unsigned chars, or it=E2=80=99s of = type unsigned char, the EOF will never be detected.

 <= /o:p>

 

 

  • while ((c =3D getchar()) !=3D EOF) if (c =3D=3D = '\n') { /* entire record is now there = */

 

=
------=_NextPart_000_0198_01D62AD4.7DF26800--