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=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16702 invoked from network); 16 May 2020 18:45:52 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 16 May 2020 18:45:52 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 0E5BB9C96C; Sun, 17 May 2020 04:45:50 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id F18EA9C9A5; Sun, 17 May 2020 04:45:25 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 8275F9C5EE; Sun, 17 May 2020 04:45:23 +1000 (AEST) Received: from loire.is.ed.ac.uk (loire.is.ed.ac.uk [129.215.16.10]) by minnie.tuhs.org (Postfix) with ESMTPS id CDC6E9C964 for ; Sun, 17 May 2020 04:45:19 +1000 (AEST) Received: from crunchie.inf.ed.ac.uk (crunchie.inf.ed.ac.uk [129.215.202.41]) by loire.is.ed.ac.uk (8.14.7/8.14.7) with ESMTP id 04GIjHLZ031568 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 May 2020 19:45:17 +0100 Received: from macaroni.inf.ed.ac.uk (macaroni.inf.ed.ac.uk [129.215.197.42]) by crunchie.inf.ed.ac.uk (8.14.7/8.14.7) with ESMTP id 04GIjGQN025145; Sat, 16 May 2020 19:45:16 +0100 Received: by macaroni.inf.ed.ac.uk (Postfix, from userid 26013) id EBFC22D2F140; Sat, 16 May 2020 19:45:16 +0100 (BST) From: Richard Tobin To: Paul Winalski , The Eunuchs Hysterical Society In-Reply-To: Paul Winalski's message of Sat, 16 May 2020 12:28:01 -0400 X-Mailer: Ream 5.1.51-richard-mac Message-Id: <20200516184516.EBFC22D2F140@macaroni.inf.ed.ac.uk> Date: Sat, 16 May 2020 19:45:16 +0100 (BST) X-Edinburgh-Scanned: at loire.is.ed.ac.uk with MIMEDefang 2.84, Sophie, Sophos Anti-Virus, Clam AntiVirus Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 129.215.16.10 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: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" > The function prototype for getchar() is: int getchar(void); > > It returns an int, not a char. In all likelihood this is specifically > *because* EOF is defined as -1. It would have probably returned int anyway, because of the automatic promotion of char to int in expressions. It was natural to declare functions returning char as int, if you bothered to declare them at all. As K&R1 said: Since char promotes to int in expressions, there is no need to declare functions that return char. Similarly functions that might return short or float would normally return int or double; there aren't separate atof and atod functions for example. -- Richard -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.