HP SunSoft Pascal 4.0 Manuel d'utilisateur Page 168

  • 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 167
144 Pascal 4.0 Users Guide
7
Fixed Arrays
The Pascal procedure,
FixVec.p
type
TVec = array [0..8] of integer;
procedure FixVec (
var V: TVec;
var Sum: integer
);
var
i: integer;
begin
Sum := 0;
for i := 0 to 8 do
Sum := Sum + V[i];
end;
The C++ main program,
FixVedMain.cc
#include <stdio.h>
extern "C" void FixVec (
int [],
int &);
int main(void)
{
int Sum;
static int a[] = {1,2,3,4,5,6,7,8,9};
FixVec (a, Sum);
printf (" %d \n", Sum);
}
The commands to compile and
execute FixVec.p and
FixVecMain.cc
hostname% pc -c FixVec.p
hostname% CC FixVec.o FixVecMain.cc -lpc
hostname% a.out
45
Vue de la page 167
1 2 ... 163 164 165 166 167 168 169 170 171 172 173 ... 332 333

Commentaires sur ces manuels

Pas de commentaire