From: Mark Biggar <mark.a.biggar@attbi.com>
Subject: Re: how to read a file into a array???
Date: Sat, 04 May 2002 22:24:44 GMT
Date: 2002-05-04T22:24:44+00:00 [thread overview]
Message-ID: <3CD45E7D.2DA637B5@attbi.com> (raw)
In-Reply-To: 3CD430FE.B803914C@acm.org
Jeffrey Carter wrote:
>
> devine wrote:
> >
> > I'm having some problems reading a file into a array. Say the file
> > has the line
> > This is a test, how can i read each word of the file into a array? an
> > example would be helpful.
> > thanks.
>
> An array object in Ada is always a fixed size, so you have to have some
> means of deciding how big to make your array. Since words in a text file
> are different sizes, you're going to have to have array components that
> can handle different size components.
Don't bother. Slurp the whole file into one big string and then
parse and create an array of records containing indices to the
first and last character of each word. Write an access function
that takes an index and returns the corresponding slice.
--
Mark Biggar
mark.a.biggar@attbi.com
next prev parent reply other threads:[~2002-05-04 22:24 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 [this message]
2002-05-05 2:18 ` devine
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