HP SunSoft Pascal 4.0 Manuel d'utilisateur Page 139

  • 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 138
The C–Pascal Interface 115
6
Function Return Values
Function return values match types the same as with parameters, and they
pass in much the same way.
Simple Types
The simple types pass in a straightforward way, as follows:
The commands to compile and
execute ChrCAVal.p and
ChrCAValMain.c with
-calign
hostname% pc -c -calign ChrCAVal.p
hostname% cc ChrCAVal.o ChrCAValMain.c -lpc
hostname% a.out
This is a string
The Pascal function,
RetReal.p
function RetReal(x: real): real;
begin
RetReal := x + 1.0
end; { RetReal }
The C main program,
RetRealMain.c
#include <stdio.h>
extern double RetReal(double);
int main(void)
{
double r, s;
r = 2.0;
s = RetReal(r);
printf(" %f \n", s);
}
Vue de la page 138
1 2 ... 134 135 136 137 138 139 140 141 142 143 144 ... 332 333

Commentaires sur ces manuels

Pas de commentaire