122
Pascal 4.0 User’s Guide
6
The
univ
Arrays
The
univ
arrays that are
in
,
out
,
in out,
or
var
parameters pass by
reference.
Here is an example:
The C function,
UniVec.c
void UniVec(int V[3], int Last, int *Sum)
{
int i;
*Sum = 0;
for (i = 0; i <= Last; i++)
*Sum += V[i];
}
The Pascal main program,
UniVecMain.p
program UniVecMain(output);
type
TVec = array [0..9] of integer;
var
Sum: integer;
V: array [0..2] of integer;
procedure UniVec(var V: univ TVec; in Last: integer;
var Sum: integer);
external c;
begin
V[0] := 7;
V[1] := 8;
V[2] := 9;
UniVec(V, 2, Sum);
writeln(Sum);
end. { UniVecMain }
The commands to compile and
execute
UniVec.c
and
UniVecMain.p
hostname% cc -c UniVec.c
hostname% pc -calign UniVec.o UniVecMain.p
hostname% a.out
24
Содержание 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: ......