HP SunSoft Pascal 4.0 Uživatelský manuál Strana 147

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 333
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 146
The C–Pascal Interface 123
6
The -calign option is not needed for this example, but may be necessary if
the array parameter is an array of aggregates.
Conformant Arrays
For single-dimension conformant arrays, pass upper and lower bounds placed
after the declared parameter list. If the array is multidimensional, pass
element widths as well, one element width for each dimension, except the last
one. Chapter 8, “The FORTRAN–Pascal Interface,” has an example of
multidimensional conformant array passing.
The following example uses a single-dimension array:
The C function, IntCA.c void IntCA(int a[], int lb, int ub)
{
int k;
for (k=0; k <= ub - lb; k++)
a[k] = 4;
}
The Pascal main program,
IntCAMain.p. Note that what
Pascal passes as s, is received
in C as a, lb, ub.
program IntCAMain(output);
var
s: array [1..3] of integer;
i: integer;
procedure IntCA(var a: array [lb..ub: integer] of integer);
external c;
begin
IntCA(s);
for i := 1 to 3 do
write(s[i]);
writeln
end. { IntCAMain }
Zobrazit stránku 146
1 2 ... 142 143 144 145 146 147 148 149 150 151 152 ... 332 333

Komentáře k této Příručce

Žádné komentáře