Fixed arrays – HP SunSoft Pascal 4.0 User Manual

Page 168

Advertising
background image

144

Pascal 4.0 User’s Guide

7

Fixed Arrays

The Pascal procedure,

FixVec.p

type

TVec = array [0..8] of integer;

procedure FixVec (

var V: TVec;

var Sum: integer

);

var

i: integer;

begin

Sum := 0;

for i := 0 to 8 do

Sum := Sum + V[i];

end;

The C++ main program,

FixVedMain.cc

#include <stdio.h>

extern "C" void FixVec (

int [],

int &);

int main(void)

{

int Sum;

static int a[] = {1,2,3,4,5,6,7,8,9};

FixVec (a, Sum);

printf (" %d \n", Sum);

}

The commands to compile and
execute

FixVec.p

and

FixVecMain.cc

hostname% pc -c FixVec.p

hostname% CC FixVec.o FixVecMain.cc -lpc

hostname% a.out

45

Advertising