On this page
  1. size_t
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

size_t

Prev: stddef.h | Up: stddef.h | Next: ptrdiff_t
Rel: stddef.h, stdint, stdbool & limits Guide
Ref: cppreference — size_t
Tags: #public #prog #c #stdlib #stddef #tier/core


Include

#include <stddef.h>

Signature & Overview

typedef /* unsigned */ size_t;

Unsigned integer type returned by sizeof and used for object sizes and array indices.

Notes & Pitfalls

Example

#include <assert.h>
#include <stddef.h>

int main(void) {
    size_t n = 4, sum = 0;
    for (size_t i = n; i-- > 0;) sum += i;
    assert(sum == 6);
}

Linked from

Related notes