C stddef (stddef.h) Library
C stddef Types and Macros
The <stddef.h> header has some common types and macros. Many of them are also in other headers. For example, size_t and NULL are also in <stdio.h>, <stdlib.h> and <string.h>.
Example
Use size_t to store the number of elements in an array:
int numbers[] = {10, 20, 30, 40};
size_t length = sizeof(numbers) / sizeof(numbers[0]);
printf("%zu", length);
| Name | Description |
|---|---|
| size_t | An unsigned integer type for sizes, like the result of sizeof. Print it with %zu |
| ptrdiff_t | A signed integer type for the difference between two pointers. Print it with %td |
| NULL | A null pointer: a pointer that does not point to anything |
| offsetof() | Returns the position of a member inside a struct, in bytes |
| wchar_t | A type for wide characters (characters that can need more than one byte) |
| max_align_t | A type with the strictest memory alignment of all the basic types (C11) |
Related Pages
Read more in our C Memory Size Tutorial and C NULL Tutorial.