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

  • 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 123
100 Pascal 4.0 Users Guide
6
The univ Arrays
You can pass any size array to a Pascal procedure expecting a univ array,
although there is no special gain in doing so, because there is no type or size
checking for separate compilations. However, if you want to use an existing
Pascal procedure that has a univ array, you can do so. All univ arrays that
are in, out, in out, or var parameters pass by reference.
The Pascal procedure,
UniVec.p, which defines a 10-
element array
type
TVec = array [0..9] of integer;
procedure UniVec(
var V: univ TVec;
in Last: integer;
var Sum: integer);
var
i: integer;
begin
Sum := 0;
for i := 0 to Last do
Sum := Sum + V[i];
end; { UniVec }
The C main program,
UniVecMain.c, which passes
a 3-element array to the Pascal
procedure written to do a 10-
element array
#include <stdio.h>
extern void UniVec(int *, int, int *);
int main(void)
{
int Sum;
static int a[] = {7, 8, 9};
UniVec(a, 2, &Sum);
printf(" %d \n", Sum);
}
Zobrazit stránku 123
1 2 ... 119 120 121 122 123 124 125 126 127 128 129 ... 332 333

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

Žádné komentáře