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);
}
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......