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,FREEMAIL_FROM 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 17:10:06 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshub.sdsu.edu!logbridge.uoregon.edu!msunews!not-for-mail From: "Chad R. Meiners" Newsgroups: comp.lang.ada Subject: Re: Problems with Ada.Text_IO and strings. Date: Mon, 13 Oct 2003 20:06:16 -0400 Organization: Michigan State University Message-ID: References: <8336eb21.0310131423.7410e1ec@posting.google.com> NNTP-Posting-Host: arctic.cse.msu.edu X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.lang.ada:795 Date: 2003-10-13T20:06:16-04:00 List-Id: "Bleakcabal" wrote in message news:8336eb21.0310131423.7410e1ec@posting.google.com... > 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); Try Ada.Text_IO.Put(MyType.name(1..Namelength)); -- to print only the part of the string that was used. > 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. btw, is this for a class? -CRM