Sizeof Operator

Sizeof indicates the amount of storage, in bytes, associated with a type, variable, parameter or constant.

注: The sizeof operator is utilized at compile time. Generally this operator can also be used with arrays. However, when used with function parameter arrays, this operator returns the size of arrays' data types.

Syntax

SizeOf = "sizeof" "(" Expr ")".

Example

dcltrans
  transaction TMain
  var
    nNumber : number;
    fFloat : float;
    sString1 : string(12) init "ProductName";
    sString2 : string;
  begin
    write(sizeof(nNumber));  // --> 4
    write(sizeof(fFloat));   // --> 8
    write(sizeof(sString1)); // --> 13
    write(sizeof(sString2)); // --> 254
    write(sizeof("abcde"));  // --> 5
  end TMain;
注: The terminating null byte for strings is not included.