HP SunSoft Pascal 4.0 Manuale Utente Pagina 138

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 333
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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);
}
Vedere la pagina 137
1 2 ... 133 134 135 136 137 138 139 140 141 142 143 ... 332 333

Commenti su questo manuale

Nessun commento