From: bobduff@world.std.com (Robert A Duff)
Subject: Re: C to Ada : a piece of code
Date: 1996/09/07
Date: 1996-09-07T00:00:00+00:00 [thread overview]
Message-ID: <DxD7DF.3AH@world.std.com> (raw)
In-Reply-To: 3231732C.2781@virgoa4.in2p3.fr
In article <3231732C.2781@virgoa4.in2p3.fr>,
Grave Xavier <xavier@virgoa4.in2p3.fr> wrote:
>Hi,
>
>Can somebody explain me a way to translate this C code to
>Ada ? I just want to avoid using chained list for a vector
>of double.
>
>-------------------------
>double *vect;
>long size,i;
>
>scanf("%ld",&size);
>vect = (double *) calloc(size,sizeof(double));
>for(i=0;i<size;i++)
> {vect[i] = ....;
> }
>-------------------------
type My_Float is digits 8; -- or whatever
type Vector is array(Positive range <>) of My_Float;
Size: Positive := ...;
V: Vector(1..Size);
...
for I in V'Range loop
V(I) := ...;
end loop;
Or:
type Vector_Ptr is access Vector;
VP: Vector_Ptr := new Vector(1..Size);
----------------
- Bob
next prev parent reply other threads:[~1996-09-07 0:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-09-07 0:00 C to Ada : a piece of code Grave Xavier
1996-09-07 0:00 ` David C. Hoos, Sr.
1996-09-07 0:00 ` Robert A Duff [this message]
1996-09-08 0:00 ` Jon S Anthony
1996-09-08 0:00 ` David C. Hoos, Sr.
1996-09-09 0:00 ` nasser
1996-09-09 0:00 ` Jon S Anthony
1996-09-09 0:00 ` David C. Hoos, Sr.
1996-09-09 0:00 ` John G. Volan
1996-09-09 0:00 ` Robert Dewar
1996-09-10 0:00 ` Geert Bosch
1996-09-11 0:00 ` Robert Dewar
1996-09-13 0:00 ` Geert Bosch
1996-09-14 0:00 ` Robert Dewar
1996-09-11 0:00 ` Robert Dewar
1996-09-11 0:00 ` Jonas Nygren
1996-09-13 0:00 ` Geert Bosch
1996-09-14 0:00 ` Robert Dewar
1996-09-10 0:00 ` Jon S Anthony
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox