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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.xdsl-213-196-221-111.netcologne.de!not-for-mail From: Frank Buss Newsgroups: comp.lang.ada Subject: quiz for Sequential_IO Read Date: Sun, 3 Sep 2017 13:01:25 +0200 Organization: news.netcologne.de Distribution: world Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 3 Sep 2017 11:01:25 +0000 (UTC) Injection-Info: newsreader4.netcologne.de; posting-host="xdsl-213-196-221-111.netcologne.de:213.196.221.111"; logging-data="9355"; mail-complaints-to="abuse@netcologne.de" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 X-Mozilla-News-Host: news://news.netcologne.de:119 Xref: news.eternal-september.org comp.lang.ada:47906 Date: 2017-09-03T13:01:25+02:00 List-Id: What does this program output? with Ada.Sequential_IO; with Ada.Text_IO; use Ada.Text_IO; procedure Hello is type Byte is range 0..255; package Byte_IO is new Ada.Sequential_IO(Byte); A : Byte; B : Byte; C : Byte; File : Byte_IO.File_Type; begin Byte_IO.Open(File, Byte_IO.In_File, "test.txt"); Byte_IO.Read(File, A); Put_Line(Byte'Image(A)); Byte_IO.Read(File, B); Put_Line(Byte'Image(B)); C := (A mod 2) + (B mod 2); Put_Line(Byte'Image(C)); Byte_IO.Close(File); end; The content of test.txt is just the ASCII string "hello": hexdump -C test.txt: 00000000 68 65 6c 6c 6f |hello| 00000005 Answer without compiling and running it! A hex calculator is allowed. Extra brownie point if you can explain the result :-) Don't know if it matters, compiled with "gnatgcc (Debian 6.3.0-18) 6.3.0 20170516", 64 bit version, and "-g -O2" command line options. -- Frank Buss, http://www.frank-buss.de electronics and more: http://www.youtube.com/user/frankbuss