HP SunSoft Pascal 4.0 Bedienungsanleitung Seite 170

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 333
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 169
146 Pascal 4.0 Users Guide
7
Records and Structures
A Pascal record of an integer and a character string matches a C++ structure of
the same constructs, as in this example:
The commands to compile and
execute DaysOfWeek.p and
DaysOfWeekMain.cc
without
the -calign option
hostname% pc -c DaysOfWeek.p
hostname% CC DaysOfWeek.o DaysOfWeekMain.cc -lpc
hostname% a.out
Day = ''
The commands to compile and
execute DaysOfWeek.p and
DaysOfWeekMain.cc
with
the
-calign option
hostname% pc -c -calign DaysOfWeek.p
hostname% CC DaysOfWeek.o DaysOfWeekMain.cc -lpc
hostname% a.out
Day = 'Sunday'
The Pascal procedure,
StruChr.p. It is safer for the
Pascal procedure to explicitly
provide the null byte and include
it in the count before the string is
passed to C++.
type
TLenStr = record
NBytes: integer;
ChrStr: array [0..24] of char;
end;
procedure StruChr (
var v: TLenStr
);
begin
v.NBytes := 14;
v.ChrStr := 'St.Petersburg' + chr(0);
end;
Seitenansicht 169
1 2 ... 165 166 167 168 169 170 171 172 173 174 175 ... 332 333

Kommentare zu diesen Handbüchern

Keine Kommentare