6

The Pascal procedure, IntCA.p. Pascal passes the bounds pair.

The C main program,

IntCAMain.c

Examples of single-dimension, multidimension, and array-of-character conformant arrays follow. Conformant arrays are included here only because they are a relatively standard feature; there are usually more efficient and simpler ways to do the same thing.

Example 1: Single-Dimension Array

procedure IntCA(var a: array [lb..ub: integer] of integer); begin

a[1] := 1;

a[2] := 2 end; { IntCA }

#include <stdio.h>

extern void IntCA(int [], int, int);

int main(void)

{

int k ;

static int s[] = { 0, 0, 0 };

IntCA (s, 0, sizeof(s)-1); for (k=0 ; k < 3 ; k++)

printf(" %d \n", s[k]);

}

The commands to compile and execute IntCA.p and IntCAMain.c with -calign

hostname% pc -c -calign IntCA.p hostname% cc IntCA.o IntCAMain.c -lpc hostname% a.out

0

1

2

102

Pascal 4.0 User’s Guide