6
The C function, UniVec.c
The Pascal main program,
UniVecMain.p
The commands to compile and
execute UniVec.c and
UniVecMain.p
122
The univ Arrays
The univ arrays that are in, out, in out, or var parameters pass by
reference.
Here is an example:
void UniVec(int V[3], int Last, int *Sum)
{
int i;
*Sum = 0;
for (i = 0; i <= Last; i++)
*Sum += V[i];
}
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 -c UniVec.c
hostname% pc -calign UniVec.o UniVecMain.p
hostname% a.out
24
Pascal 4.0 User's Guide
Need help?
Do you have a question about the SunSoft Pascal 4.0 and is the answer not in the manual?
Questions and answers