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

  • 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 125
102 Pascal 4.0 Users Guide
6
Examples of single-dimension, multidimension, and array-of-character
conformant arrays follow. Conformant arrays are included here only because
they are a relatively standard feature; there are usually more efficient and
simpler ways to do the same thing.
Example 1: Single-Dimension Array
The Pascal procedure,
IntCA.p. Pascal passes the
bounds pair.
procedure IntCA(var a: array [lb..ub: integer] of integer);
begin
a[1] := 1;
a[2] := 2
end; { IntCA }
The C main program,
IntCAMain.c
#include <stdio.h>
extern void IntCA(int [], int, int);
int main(void)
{
int k ;
static int s[] = { 0, 0, 0 };
IntCA (s, 0, sizeof(s)-1);
for (k=0 ; k < 3 ; k++)
printf(" %d \n", s[k]);
}
The commands to compile and
execute IntCA.p and
IntCAMain.c with -calign
hostname% pc -c -calign IntCA.p
hostname% cc IntCA.o IntCAMain.c -lpc
hostname% a.out
0
1
2
Zobrazit stránku 125
1 2 ... 121 122 123 124 125 126 127 128 129 130 131 ... 332 333

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

Žádné komentáře