9.21 'sizeof' operator

-----------------------

'sizeof' operator defines the memory size of an object or type, as

follows:

sizeof (<name of type>)

'sizeof' operator gives the memory size in bytes corresponding to the

object or type.

In C-- 'sizeof' can be used with variables, registers, variable types,

structures, functions, text strings and files.

When used with a structure, 'sizeof' gives the size of its tag.

When used with a text string, it gives the size of the string plus a

terminal null. For example:

sizeof ("Test")

gives the number 5. If you write the string instead as:

char a="Test";

sizeof(a)

you get again 5, the size of the memory reserved for variable a.

When used with a structure, 'sizeof' gives the actual size of the

memory which it occupies. This is particularly important if you have

declared an array of structures.

'sizeof' can also be used with the name of a previously defined

function, to give the size of this function (which for a dynamic function

will always be zero).

'sizeof' can also be used with files. This is especially useful with

'FROM' but has other applications as well. Here is an example:

sizeof ( file "filename.dat" )

The result is the size of "filename.dat".