From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8d5bda3619cce0f8 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.germany.com!feeder2.news.saunalahti.fi!fi.sn.net!newsfeed2.fi.sn.net!news.song.fi!not-for-mail Date: Tue, 17 Feb 2009 10:16:52 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: C getchar() functionality in Ada References: <4999ce31$0$90266$14726298@news.sunsite.dk> <%5lml.519385$TT4.153916@attbi_s22> <499a6607$0$90276$14726298@news.sunsite.dk> In-Reply-To: <499a6607$0$90276$14726298@news.sunsite.dk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <499a71f2$0$14834$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: 81.17.205.61 X-Trace: 1234858482 news.tdc.fi 14834 81.17.205.61:32805 X-Complaints-To: abuse@tdcnet.fi Xref: g2news2.google.com comp.lang.ada:4637 Date: 2009-02-17T10:16:52+02:00 List-Id: Thomas Locke wrote: > Jeffrey R. Carter wrote: > >> This is one of the latter cases. You should not be using Character, >> String, or Ada.Text_IO for this. I suggest you look at streams and >> Ada.Text_IO.Text_Streams. Or Ada.Sequential_IO, instantiated for Character (or Storage_Element, etc.) which seems to me the best match to the original C program. However, Sequential_IO has the problem that the standard-input and standard-output channels are not accessible, you must Open named files. > I will try this when my Ada skills have improved a bit. For now I will > focus on learning how to best use Text_IO. > > I wouldn't mind a smallish example on using Ada.Text_IO.Text_Streams > though... :D Here is a copy-input-to-output program with Text_Streams and Character: with Ada.Text_IO.Text_Streams; procedure Acopy is use Ada.Text_IO; use Ada.Text_IO.Text_Streams; Input : constant Stream_Access := Stream (Standard_Input); Output : constant Stream_Access := Stream (Standard_Output); Item : Character; begin while not End_Of_File (Standard_Input) loop Character'Read (Input , Item); Character'Write(Output, Item); end loop; end Acopy; -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .