HP SunSoft Pascal 4.0 Instrukcja Użytkownika Strona 149

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 333
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 148
The C–Pascal Interface 125
6
Variant Records
C equivalents of variant records can sometimes be constructed, although there
is some variation with the architecture, and sometimes you have to adjust the
alignment.
The Pascal main program,
StruChrMain.p
program StruChrMain(output);
type
TVarLenStr = record
nbytes: integer;
a: array [0..25] of char
end;
var
vls: TVarLenStr;
i: integer;
procedure StruChr(var vls: TVarLenStr); external c;
begin
StruChr(vls);
write(' string=''');
for i := 0 to vls.nbytes - 1 do
write(vls.a[i]);
writeln('''');
writeln(' length = ', vls.nbytes)
end. { StruChrMain }
The commands to compile and
execute StruChr.c and
StruChrMain.p
hostname% cc -c StruChr.c
hostname% pc -calign StruChr.o StruChrMain.p
hostname% a.out
string=' strvar'
length= 6
Przeglądanie stron 148
1 2 ... 144 145 146 147 148 149 150 151 152 153 154 ... 332 333

Komentarze do niniejszej Instrukcji

Brak uwag