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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,49f7dd1bad1910ff X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-13 16:50:11 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!falcon.america.net!eagle.america.net.POSTED!not-for-mail From: Larry Hazel User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Problems with Ada.Text_IO and strings. References: <8336eb21.0310131423.7410e1ec@posting.google.com> In-Reply-To: <8336eb21.0310131423.7410e1ec@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 13 Oct 2003 18:51:07 -0500 NNTP-Posting-Host: 66.0.32.41 X-Trace: eagle.america.net 1066089010 66.0.32.41 (Mon, 13 Oct 2003 19:50:10 EDT) NNTP-Posting-Date: Mon, 13 Oct 2003 19:50:10 EDT Organization: 24hoursupport.com Xref: archiver1.google.com comp.lang.ada:794 Date: 2003-10-13T18:51:07-05:00 List-Id: Bleakcabal wrote: > Hi, im new to Ada and I am writing my first program trying to "get" > Ada. > > My small program ask for input from the user. I read it using : > > Ada.Text_IO.Get_Line (MyType.Name, NameLength); > > This data is then stored inside an array of a type I have declared : > > type MyType is record > name : string(1..20); > adress : string(1..40); > telephone : natural; > end record; > > Later in the program I output this information using : > Ada.Text_IO.Put (MyType.name); > > My problem is this : when I output the name, part of the string is > filled with "garbage" characters. If I fill the string with 20 > characters I get no garbage. But when I write a name that's about 10 > characters long, I get about 10 characters of garbage. > > Im using Gnat as my Ada compiler if that makes a difference. > > Any help would be appreciated. > > Thank you in advance. First off, you need a variable of type MyType to read into, but I expect you do have that. Ada.Text_IO.Get_Line reads NameLength characters into the name field. If you enter 10 characters, then NameLength is 10 and MyRecord.Name(11..20) will be unchanged, probably garbage characters.