![](/images/backgrounds/286549/hp-sunsoft-pascal-4-0-users-manual-549395146x1.png)
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
The commands to compile and execute UniVec.c and
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 }
hostname% cc
hostname% pc
24
122 | Pascal 4.0 User’s Guide |