comp.lang.ada
 help / color / mirror / Atom feed
From: Jim Rogers <jimmaureenrogers@att.net>
Subject: Re: unbound array?
Date: Mon, 26 Jul 2004 03:10:42 GMT
Date: 2004-07-26T03:10:42+00:00	[thread overview]
Message-ID: <Xns9531D779E606Djimmaureenrogers@127.0.0.1> (raw)
In-Reply-To: 41046a70@dnews.tpgi.com.au

"John Clarke" <jclarke@abit.com.au> wrote in
news:41046a70@dnews.tpgi.com.au: 

> Hello!
> 
> I was hoping someone could shed some light. I am writing an ADA
> program that reads a file and counts the number of words in the text
> file and stores the word length, of each word encountered, in an
> array. So for instance i have defined:
> 
> size : integer := 100;
> type length_type is array (1..size) of integer;
> word_length : length_type;
> 
> Now, if the text file is: "A rat was here."
> 
> Hence, word_length(1) = 1, word_length(2) = 3, word_length(4) = 4
> etc... 
> 
> The problem I am facing is that I don't know how many words I will
> encounter in the text file. I do not want to constrain size to 100 as
> I have above. I know I can use unconstrained array type, but this also
> doesn't solve the problem as an unconstrained array requires a
> predefined size assigned prior to assigning values to it.
> 
> I know that size will never be greater than the number of characters
> in the text file. But it would be a little ridiculous assigning "size"
> = "number of characters in text file".
> 
> How can this problem be solved? Any help would be great.
> 

Does the result have to be stored in an array?
Can it be stored in a list instead?

Jim Rogers




  reply	other threads:[~2004-07-26  3:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-26  2:20 unbound array? John Clarke
2004-07-26  3:10 ` Jim Rogers [this message]
2004-07-26  5:43 ` tmoran
2004-07-26 11:37 ` Martin Krischik
2004-07-28 14:09   ` zork
replies disabled

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