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=HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31740 invoked from network); 24 Jul 2020 04:43:14 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 24 Jul 2020 04:43:14 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 523009C9F5; Fri, 24 Jul 2020 14:43:11 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id B129E9C8DE; Fri, 24 Jul 2020 14:42:07 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 939B29C8DE; Fri, 24 Jul 2020 14:42:04 +1000 (AEST) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by minnie.tuhs.org (Postfix) with ESMTPS id A7F759C8B1 for ; Fri, 24 Jul 2020 14:42:03 +1000 (AEST) Received: by mail-pl1-f169.google.com with SMTP id x8so3808507plm.10 for ; Thu, 23 Jul 2020 21:42:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iJg2jQfXsMEO3Mu/xvQBiR9BZrBk8rdN/gKq+tLyvAE=; b=nzX9dhWR/XlFhRXGFexA9AWQaVmJ52lnwMW2AmkfhPby3BagW7AlcSrneok3ihhPSW or3i8yRFFKUBrVdc/5aCSSisQ4Fnk3Bn9ZrdNMie2lAhfznHnslXaZS9p7WCXE3wB+J9 DwEaLkk1R5HGrTAs0LgNDEKFpB+TtmEpnFgMFTkzUTl0VPSRIf2F84ZZfZUgSHUAOO9b dUdj91FhyX49U6wPE4bDWw4l5Z6he79T2YlNBoWvqCOJIUGsCUOB39aJdG48vnnQFjZh 0xHDq6pJEioOI2L8CjcJlQRGa30+7oKgRVpRcsoBIrpCI0pjZlMhhCGa6xJHofTdlFjC l7Pg== X-Gm-Message-State: AOAM532svcQgR+um6+KqfxLu4/rexGcdzrIODGBz6Iy6rrYF+WsYLTyx Xa5qU8ziZT+GR/aupnMezdCLlv5KJpM49BrEmou2In7y X-Google-Smtp-Source: ABdhPJz6qOOpeD7hviaa/9yscqj1uxzp4Bf4/H33kA3yEM4UVbSG4FHx7D8BAdCNBN9sJM4g7jkq4oEapWOUoPgGPh4= X-Received: by 2002:a17:902:d909:: with SMTP id c9mr6463768plz.225.1595565722363; Thu, 23 Jul 2020 21:42:02 -0700 (PDT) MIME-Version: 1.0 References: <20200724025712.GL10855@mcvoy.com> In-Reply-To: <20200724025712.GL10855@mcvoy.com> From: Paul Riley Date: Fri, 24 Jul 2020 12:41:38 +0800 Message-ID: To: Larry McVoy Content-Type: multipart/alternative; boundary="00000000000018ebaa05ab28983a" Subject: Re: [TUHS] V6 Console IO 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: tuhs Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --00000000000018ebaa05ab28983a Content-Type: text/plain; charset="UTF-8" Larry, Thanks for that. The documentation for putchar says that it only puts the low byte of the argument, so I assume that passing an int is ok. Paul *Paul Riley* On Fri, 24 Jul 2020 at 10:57, Larry McVoy wrote: > > int main() { > > int c; > > while ((c = getchar()) != EOF) { > > putchar(c); > > } > > } > > int > main() > { > int c; > char C; > > while ((c = getchar()) != EOF) { > C = c; > write(1, &C, 1); > } > } > --00000000000018ebaa05ab28983a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Larry,

Thanks for that. The documentati= on for putchar says that it only puts the low byte of the argument, so I as= sume that passing an int is ok.

Paul
=
Paul Riley


On Fri, 24 Jul 2020 at = 10:57, Larry McVoy <lm@mcvoy.com>= wrote:
> int= main() {
> int c;
> while ((c =3D getchar()) !=3D EOF) {
> putchar(c);
> }
> }

int
main()
{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int=C2=A0 =C2=A0 =C2=A0c;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char=C2=A0 =C2=A0 C;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 while ((c =3D getchar()) !=3D EOF) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 C =3D c;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 write(1, &C, 1)= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
}
--00000000000018ebaa05ab28983a--