comp.lang.ada
 help / color / mirror / Atom feed
From: devine@linuxmail.org (devine)
Subject: Re: how to read a file into a array???
Date: 4 May 2002 19:18:41 -0700
Date: 2002-05-05T02:18:42+00:00	[thread overview]
Message-ID: <e6a474c.0205041818.6c4ed9d0@posting.google.com> (raw)
In-Reply-To: 3CD45E7D.2DA637B5@attbi.com

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);
   
END Test;

This is what I was playing around with.  How can I change it so that
it reads the file and each word is read instead of each character?  i
put character at the top because i wasn't sure what to put their.  I
will need something that checks for the whitespace inbetween the words
right?



  reply	other threads:[~2002-05-05  2:18 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 [this message]
2002-05-05  3:52       ` Dale Stanbrough
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