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,fbb7003b9d2e8c21 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-04 20:52:41 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!deine.net!intgwpad.nntp.telstra.net!news.telstra.net!news-server.bigpond.net.au!not-for-mail From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Re: how to read a file into a array??? References: <3CD430FE.B803914C@acm.org> <3CD45E7D.2DA637B5@attbi.com> User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X) Message-ID: Date: Sun, 05 May 2002 03:52:38 GMT NNTP-Posting-Host: 144.132.91.90 X-Complaints-To: news@bigpond.net.au X-Trace: news-server.bigpond.net.au 1020570758 144.132.91.90 (Sun, 05 May 2002 13:52:38 EST) NNTP-Posting-Date: Sun, 05 May 2002 13:52:38 EST Organization: BigPond Internet Services (http://www.bigpond.net.au) Xref: archiver1.google.com comp.lang.ada:23552 Date: 2002-05-05T03:52:38+00:00 List-Id: devine@linuxmail.org (devine) wrote: > This is what I have so far: > WITH Ada.Text_IO; > WITH Ada.Integer_Text_IO; > PROCEDURE Test IS > > FileName : String(1..80); > MaxName : CONSTANT Positive := 80; > SUBTYPE NameRange IS Positive RANGE 1..MaxName; > Length : NameRange; > InFile : Ada.Text_IO.File_Type; > y: integer; > Max : CONSTANT Integer := 999999; > SUBTYPE Size IS Integer RANGE 0..Max; > TYPE TestArray IS ARRAY (Size) OF Character; > X : TestArray; > > BEGIN > > Ada.Text_IO.Put (Item => "Enter the name of the file > "); > Ada.Text_IO.Get_Line(Item => FileName, Last => Length); > Ada.Text_IO.New_Line; > Ada.Text_IO.Open(File => InFile, Mode => Ada.Text_IO.In_File, Name > => FileName(1..Length)); > > Y:=0; > LOOP > EXIT WHEN Ada.Text_IO.End_Of_File(InFile); > Y:=Y+1; > Ada.Text_IO.Get(File => InFile, Item => X(Y)); > Ada.Text_IO.New_Line; > END LOOP; > > Ada.Integer_Text_IO.Put(y); Using Mike Feldman's text book? I wonder who set this assignment... There is no magic that Ada will provide you to solve this problem. You have to figure out how to store a word, or how to know where a word starts and ends. You should be able to draw a picture of how your data will be structured, and be able to explain it to someone coherently before you start coding. Then you have to transfer that idea into code. Dale