HP SunSoft Pascal 4.0 Manuel d'utilisateur Page 138

  • 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 137
114 Pascal 4.0 Users 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);
}
Vue de la page 137
1 2 ... 133 134 135 136 137 138 139 140 141 142 143 ... 332 333

Commentaires sur ces manuels

Pas de commentaire