File:  [MW Coherent from dump] / coherent / a / usr / man / ALL / sizeof
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:34 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent



sizeof                      C Keyword                      sizeof




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 lloonngg is as long as four cchhaarrs.

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", "Mark Williams C for the Atari ST",
        "Let's C", "Fast Forward"
};



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 in-
crease the portability of your code.

***** See Also *****

C keywords, data types, operators














COHERENT Lexicon                                           Page 1



unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.