HP SunSoft Pascal 4.0 Manuel d'utilisateur Page 147

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 333
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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 }
Vue de la page 146
1 2 ... 142 143 144 145 146 147 148 149 150 151 152 ... 332 333

Commentaires sur ces manuels

Pas de commentaire