comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: End of a string????
Date: 2000/10/10
Date: 2000-10-10T00:00:00+00:00	[thread overview]
Message-ID: <8rvsj9$m1e$1@nnrp1.deja.com> (raw)
In-Reply-To: MPG.144cf9c2da936cef98968d@news.prodigy.net

In article <MPG.144cf9c2da936cef98968d@news.prodigy.net>,
  Ryuji Yokoyama <stiletto@ryuji.net> wrote:

> How can I find the end of string in ada?  Is there any special
> character at the end of line like C's \0?  Or is there any function
> to find the length of a string like Java's Mystring.length()?  I
> tried myString'length, but it just gives me the size of array.

In Ada the length of the string *is* the length of the array.

If you have some kind of logical end of the data within the string, you
either have to create your string object exactly that length, or keep
track of the end index in a separate variable and use subranges (eg:
"MyString(1..MyString_Length)" ).

As Tom mentioned, another option is to use
Ada.Strings.Unbounded.Unbounded_String or
Ada.Strings.Bounded.Bounded_String, which will allow you to use
varying-length strings without having to use subranges. But if the
string doesn't change after it gets its initial value, you are probably
better off just declaring it there with the exact size you will need.

For more information on this subject, consult our FAQ at
http://www.adapower.com/lab/adafaq/24.html .


--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html
Day 5 of Free Europe


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-10-10  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-10  0:00 End of a string???? Ryuji Yokoyama
2000-10-10  0:00 ` Ted Dennison [this message]
2000-10-10  0:00 ` tmoran
2000-10-13  0:00 ` Per Sandberg
2000-10-13  0:00   ` Wes Groleau
2000-10-13  0:00     ` David C. Hoos, Sr.
2000-10-14  0:00       ` Wes Groleau
replies disabled

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