From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: ada language
Date: Tue, 3 Dec 2002 10:22:57 +0000 (UTC)
Date: 2002-12-03T10:22:57+00:00 [thread overview]
Message-ID: <slrnaup1g0.id.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: 4f6087a5.0212030105.43712e2b@posting.google.com
* satish umakar wrote:
> how to convert a array of characters(characters stored in a array read
> from a file) to a string type.
The language defines:
type String is array (Positive range <>) of Characters;
So there is no difference between an array of Characters and a String,
besides the String is a new type and the array is a different type.
Therefore simply assign it, as long as the offsets does not cause a
constraint problem:
procedure t is
type Array_of_Character is array (Integer range <>) of Character;
a : Array_of_Character := (-3 => 'H', -2 => 'e', -1|0 => 'l', 1 => 'o');
b : constant Array_of_Character (1 .. a'Length) := a;
s : String := String (b);
begin
null;
end t;
If the domains of the offset types do not overlap, you have a problem. You
will even have a problem when copying takes to much time or ressources:
procedure t is
type Negative is new Integer range Integer'First .. -1;
type Array_of_Character is array (Negative range <>) of Character;
a : Array_of_Character := (-5 => 'H', -4 => 'e', -3|-2 => 'l', -1 => 'o');
s : String (1 .. a'Length);
pragma Import (Ada, s); -- Suppress initialising.
for s'Address use a'Address; -- Map array content.
begin
null;
end t;
next prev parent reply other threads:[~2002-12-03 10:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-03 9:05 ada language satish umakar
2002-12-03 10:22 ` Lutz Donnerhacke [this message]
2002-12-03 14:40 ` Charlie McCutcheon
2002-12-04 16:05 ` Richard Riehle
2002-12-04 16:19 ` Jean-Pierre Rosen
2002-12-04 17:14 ` David C. Hoos
2002-12-04 17:10 ` Larry Kilgallen
2002-12-04 21:44 ` Bruce Hennessy
2002-12-12 1:54 ` Nick Roberts
2002-12-04 21:14 ` Ted Dennison
2002-12-07 13:02 ` Per Sandbergs
[not found] <CT.1E53xds13@ficc.uu.net>
1990-03-03 5:09 ` Ada language William Thomas Wolfe, 2847
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox