On this page
<stdint.h>, <stdbool.h> & <limits.h>
Prev: stdlib.h & string.h | Up: stdlib | Next: math, time & assert
Rel: Syntax, Types & Operators, Binary & Encodings
Ref: cppreference — Fixed Width Integer Types
Tags: #public #prog #c #stdlib #types
Contents
Portable Widths & Format Macros (<inttypes.h>)
Use <stdint.h> types for wire formats, binary files, and bit manipulation, paired with <inttypes.h> PRI* macros for portable printf:
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
uint64_t bytes = 1048576ULL;
bool ready = true;
printf("bytes=%" PRIu64 " ready=%s\n", bytes, ready ? "true" : "false");
size_t, ptrdiff_t & uintptr_t
size_t(<stddef.h>): unsigned type returned bysizeofand used for array lengths/indices (%zu).ptrdiff_t(<stddef.h>): signed result of subtracting two pointers (%td).uintptr_t(<stdint.h>): unsigned integer wide enough to hold a pointer value for alignment arithmetic.
Linked from
- tuts/c/fundamentals/syntax_types_and_operators
- tuts/c/stdlib
- tuts/c/stdlib/limits
- tuts/c/stdlib/limits/CHAR_BIT
- tuts/c/stdlib/limits/DBL_EPSILON
- tuts/c/stdlib/limits/INT_MAX
- tuts/c/stdlib/math_time_and_assert
- tuts/c/stdlib/stdbool
- tuts/c/stdlib/stdbool/bool
- tuts/c/stdlib/stddef
- tuts/c/stdlib/stddef/max_align_t
- tuts/c/stdlib/stddef/NULL
- tuts/c/stdlib/stddef/offsetof
- tuts/c/stdlib/stddef/ptrdiff_t
- tuts/c/stdlib/stddef/size_t
- tuts/c/stdlib/stdint
- tuts/c/stdlib/stdint/int32_t
- tuts/c/stdlib/stdint/int64_t
- tuts/c/stdlib/stdint/PRIu64
- tuts/c/stdlib/stdint/SIZE_MAX
- tuts/c/stdlib/stdint/uint32_t
- tuts/c/stdlib/stdint/uint64_t
- tuts/c/stdlib/stdint/uint8_t
- tuts/c/stdlib/stdint/uintptr_t
- tuts/c/stdlib/stdint_stdbool_and_limits
- tuts/c/stdlib/stdlib_and_string_h
Related notes
- tuts/c/stdlib Linked here; links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/math_time_and_assert Linked here; links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdlib_and_string_h Linked here; links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/fundamentals/syntax_types_and_operators Linked here; links to this page; shared tags: #c, #prog
- tuts/c/stdlib/limits links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/limits/CHAR_BIT links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/limits/DBL_EPSILON links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/limits/INT_MAX links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdbool links to this page; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdbool/bool links to this page; shared tags: #c, #prog, #stdlib