Lesson 112 +10 XP

void - No Type

void - No Type

void means "no type" in three contexts.

1. No return value

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

2. No parameters

int main(void) { ... }

3. Generic pointer

void *ptr;

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

Example

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.