On this page
  1. const
  2. Availability
  3. Syntax & Overview
  4. Notes & Pitfalls
  5. Example

const

Prev: __STDC_VERSION__ | Up: builtins | Next: static
Rel: Pointers & Pointer Arithmetic
Ref: cppreference — const
Tags: #public #prog #c #builtins #tier/core


Availability

Built-in (Type Qualifier) — requires no #include header.

Syntax & Overview

const T x;  |  const T *p;

Marks an object or pointee as read-only through that access path.

Notes & Pitfalls

Example

#include <assert.h>
#include <string.h>

static size_t measure(const char *s) { return strlen(s); }
int main(void) { assert(measure("immutable") == 9); }

Linked from

Related notes