COHERENT manpages
This page displays the COHERENT manpage for sizeof [Return size of a data element].
List of available manpages
Index
sizeof -- C Keyword
Return size of a data element
sizeof is a C operator that returns a constant int that gives the size of
any given data element. The element examined can be a data object, a
portion of a data object, or a type cast. sizeof returns the size of the
element in chars; for example
long foo;
sizeof foo;
returns four, because a long is as long as four chars.
sizeof can also tell you the size of an array. This is especially helpful
for use with external arrays, whose size can be set when they are
initialized. For example:
char *arrayname[] = {
"COHERENT",
"COHware volume I",
"COHERENT Device Driver Kit",
"GNU C/C++"
};
main()
{
printf("\"arrayname\" has %d entries\n",
sizeof(arrayname)/sizeof char*);
}
sizeof is especially useful in malloc() routines, and when you need to
specify byte counts to I/O routines. Using it to set the size of data
types instead of using a predetermined value will increase the portability
of your code.
See Also
C keywords,
data types,
operators
ANSI Standard, §6.3.3.4