
114 Pascal 4.0 User’s Guide
6
Arrays
Since C cannot pass arrays by value, it cannot pass strings of characters, fixed
arrays, or univ arrays by value.
Conformant Arrays
Pascal passes all value parameters on the stack or in registers, except for value
conformant array parameters, which are handled by creating a copy in the
caller environment and passing a pointer to the copy. In addition, the bounds
of the array must be passed (see “Conformant Arrays” on page 101).
This example is the same as the single-dimension example in “Conformant
Arrays,” except that the var prefix is deleted.
The Pascal procedure,
ChrCAVal.p
procedure ChrCAVal(a: array [lb..ub: integer] of char);
begin
a[0] := 'T';
a[13] := 'o';
end; { ChrCAVal }
The C main program,
ChrCAValMain.c
#include <stdio.h>
extern void ChrCAVal(char [], int, int);
int main(void)
{
static char s[] = "This is a string";
ChrCAVal(s, 0, sizeof(s) -1);
printf(" %11s \n", s);
}
Kommentare zu diesen Handbüchern