![](/images/backgrounds/286549/hp-sunsoft-pascal-4-0-users-manual-549395129x1.png)
6
The commands to compile and execute ChrCAVar.p and
ChrCAVarMain.c
hostname% pc
hostname% a.out This is a string
In most cases, a Pascal record describes the same objects as its C structure equivalent, provided that the components have compatible types and are declared in the same order. The compatibility of the types depends mostly on size and alignment. For more information on size and alignments of simple components, see “Compatibility of Types for C and Pascal” on page 90.
By default, the alignment of a record is always four bytes and the size of a record is always a multiple of four bytes. However, when you use
A Pascal record of an integer and a character string matches a C structure of the same constructs, as follows:
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; { StruChr }
The | 105 |