Namespaces
Variants
Views
Actions

size_t

From cppreference.com
< c‎ | types
Revision as of 22:43, 31 May 2013 by P12bot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Defined in header <stddef.h>
Defined in header <stdio.h>
Defined in header <string.h>
Defined in header <time.h>
typedef /*implementation-defined*/ size_t;

size_t is the unsigned integer type of the result of the sizeof operator and the alignof operator.

[edit] Notes

size_t can store the maximum size of a theoretically possible object of any type (including array). On many platforms (an exception are systems with segmented addressing) size_t can safely store the value of any non-member pointer, in which case it is synonymous with uintptr_t.

size_t is commonly used for array indexing and loop counting. Programs that use other types, such as unsigned int, for array indexing may fail on, e.g. 64-bit systems when the index exceeds UINT_MAX or if it relies on 32-bit modular arithmetic.

[edit] See also

signed integer type returned when subtracting two pointers
(typedef) [edit]
byte offset from the beginning of a struct type to specified member
(function macro) [edit]