Lesson 112 +10 XP

void - No Type

void means "no type" in three contexts.

1. No return value


c
void greet() {
    printf("Hi!");
}

2. No parameters


c
int main(void) { ... }

3. Generic pointer


c
void *ptr;

A void pointer can point to anything; cast to a real type before using.

Example


c
void *data = malloc(100);
int *numbers = (int *)data;

TL;DR

  • "No value".
  • void return: nothing returned.
  • void parameter: takes nothing.
  • void *: generic pointer, cast to use.