HP SunSoft Pascal 4.0 Manuel d'utilisateur Page 126

  • 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 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
Vue de la page 125
1 2 ... 121 122 123 124 125 126 127 128 129 130 131 ... 332 333

Commentaires sur ces manuels

Pas de commentaire