100
Pascal 4.0 User’s Guide
6
The
univ
Arrays
You can pass any size array to a Pascal procedure expecting a
univ
array,
although there is no special gain in doing so, because there is no type or size
checking for separate compilations. However, if you want to use an existing
Pascal procedure that has a
univ
array, you can do so. All
univ
arrays that
are
in
,
out
,
in out
, or
var
parameters pass by reference.
The Pascal procedure,
UniVec.p
, which defines a 10-
element array
type
TVec = array [0..9] of integer;
procedure UniVec(
var V: univ TVec;
in Last: integer;
var Sum: integer);
var
i: integer;
begin
Sum := 0;
for i := 0 to Last do
Sum := Sum + V[i];
end; { UniVec }
The C main program,
UniVecMain.c
, which passes
a 3-element array to the Pascal
procedure written to do a 10-
element array
#include <stdio.h>
extern void UniVec(int *, int, int *);
int main(void)
{
int Sum;
static int a[] = {7, 8, 9};
UniVec(a, 2, &Sum);
printf(" %d \n", Sum);
}
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......