146
Pascal 4.0 User’s 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;
Summary of Contents for SunSoft Pascal 4.0
Page 14: ...xiv Pascal 4 0 User s Guide ...
Page 16: ...xvi Pascal 4 0 User s Guide ...
Page 30: ...6 Pascal 4 0 User s Guide 1 ...
Page 160: ...136 Pascal 4 0 User s Guide 6 ...
Page 268: ...244 Pascal 4 0 User s Guide 11 ...
Page 320: ...296 Pascal 4 0 User s Guide B ...
Page 331: ...Index 307 ...
Page 333: ......