HP SunSoft Pascal 4.0 User Manual Page 168

  • Download
  • Add to my manuals
  • Print
  • Page
    / 333
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 167
144 Pascal 4.0 Users 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
Page view 167
1 2 ... 163 164 165 166 167 168 169 170 171 172 173 ... 332 333

Comments to this Manuals

No comments