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

void

Prev: _Noreturn | Up: builtins | Next: char
Rel: Pointers & Pointer Arithmetic
Ref: cppreference — void
Tags: #public #prog #c #builtins #tier/core


Availability

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

Syntax & Overview

void fn(void);  |  void *ptr;

Represents the absence of a value (empty return or parameter list) or an untyped generic object pointer (void *).

Notes & Pitfalls

Example

#include <assert.h>

static int answer(void) { return 42; }
int main(void) {
    int x = answer();
    void *vp = &x;
    int *ip = vp;
    assert(*ip == 42);
}

Linked from

Related notes