Namespaces
Variants
Views
Actions

size_t

From cppreference.com
< c‎ | types
Revision as of 14:19, 2 November 2012 by P12bot (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <stddef.h>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <stdio.h>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <string.h>
</td>

<td></td> <td></td> <tr class="t-dsc-header">

<td>
Defined in header <time.h>
</td>

<td></td> <td></td> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td class="t-dcl-nopad">
typedef /*implementation-defined*/ size_t;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

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

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.

See also

Template:c/types/dcl list ptrdiff tTemplate:c/types/dcl list offsetof