comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: How to write "Hello" to a text file without a line terminator
Date: Sat, 13 Aug 2016 11:03:42 -0700
Date: 2016-08-13T11:03:42-07:00	[thread overview]
Message-ID: <nonne4$606$1@dont-email.me> (raw)
In-Reply-To: <41b076f1-66b0-4142-8b91-0e717b6176c2@googlegroups.com>

On 08/13/2016 02:12 AM, AdaMagica wrote:
> 
> No, it's not spaces, it's the length of the string output: Since (on my machine), Integer'Size=32, it's four bytes.
> Let'say, yout output
>   Write (f, "abcdef");
> You'll get (in bytes):
>   6 0 0 0 97 98 99 100 101 102
> And for a length of 256, you'll get:
>   0 1 0 0 ...

I was thinking 2 4-byte bounds, but on my 64-bit machine with 32-bit Integer, I
get a 6 followed by 7 zeros:

with Ada.Sequential_IO;
with Ada.Text_IO;

procedure Str_Seq_IO is
   package Str_IO is new Ada.Sequential_IO (Element_Type => String);

   File : Str_IO.File_Type;
begin -- Str_Seq_IO
   Ada.Text_IO.Put_Line (Item => Integer'Image (Integer'Size) );
   Str_IO.Create (File => File, Mode => Str_IO.Out_File, Name => "junk");
   Str_IO.Write (File => File, Item => "abcdef");
   Str_IO.Close (File => File);
end Str_Seq_IO;

$ ./str_seq_io
 32
$ hd junk
00000000  06 00 00 00 00 00 00 00  61 62 63 64 65 66        |........abcdef|
0000000e

-- 
Jeff Carter
"Who wears beige to a bank robbery?"
Take the Money and Run
144


  reply	other threads:[~2016-08-13 18:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12  4:05 How to write "Hello" to a text file without a line terminator Jerry
2016-08-12  6:41 ` G.B.
2016-08-12  7:23 ` Dmitry A. Kazakov
2016-08-12  7:41   ` J-P. Rosen
2016-08-12  7:46     ` Jerry
2016-08-12  7:44   ` Jerry
2016-08-12 17:34     ` Jeffrey R. Carter
2016-08-13  3:21       ` Jerry
2016-08-13  4:23         ` Jeffrey R. Carter
2016-08-13  9:12           ` AdaMagica
2016-08-13 18:03             ` Jeffrey R. Carter [this message]
2016-08-14  7:58               ` AdaMagica
2016-08-14  8:30                 ` Simon Wright
2016-08-14  8:54                   ` Dmitry A. Kazakov
2016-08-14  9:40                     ` Simon Wright
2016-08-14 10:17                       ` Dmitry A. Kazakov
2016-08-14 11:28                         ` Simon Wright
2016-08-14 13:31                           ` Dmitry A. Kazakov
2016-08-15 23:35                       ` Randy Brukardt
2016-08-14 13:28                   ` AdaMagica
2016-08-14 13:54                     ` Simon Wright
2016-08-14 17:05                     ` Jeffrey R. Carter
2016-08-14 18:26                       ` AdaMagica
2016-08-14 19:19                         ` Dmitry A. Kazakov
2016-08-14 13:32                   ` AdaMagica
2016-08-14 16:39                   ` Jeffrey R. Carter
2016-08-12  7:46   ` Simon Wright
     [not found]   ` <noka54$ci$1@dont-email.me>
2016-08-12 13:44     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox