comp.lang.ada
 help / color / mirror / Atom feed
From: Dale Stanbrough <dstanbro@bigpond.net.au>
Subject: Re: how to read a file into a array???
Date: Sun, 05 May 2002 03:52:38 GMT
Date: 2002-05-05T03:52:38+00:00	[thread overview]
Message-ID: <dstanbro-4D390D.13523805052002@mec2.bigpond.net.au> (raw)
In-Reply-To: e6a474c.0205041818.6c4ed9d0@posting.google.com

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



  reply	other threads:[~2002-05-05  3:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-04 18:35 how to read a file into a array??? devine
2002-05-04 19:05 ` Jeffrey Carter
2002-05-04 22:24   ` Mark Biggar
2002-05-05  2:18     ` devine
2002-05-05  3:52       ` Dale Stanbrough [this message]
2002-05-17  8:50       ` GNU Readline ? Sylvain NAHAS
2002-05-17 10:25         ` Adrian Knoth
2002-05-17 19:21           ` Thomas Dickey
2002-05-05  6:20     ` how to read a file into a array??? Simon Wright
replies disabled

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