Values & References16 / 18
Up next

Pointer to pointer

#include <stdio.h>
#include <stdlib.h>

void make(int **out, int value) {
    *out = malloc(sizeof **out);
    **out = value;
}

int main(void) {
    int *p = nullptr;
    make(&p, 99);
    printf("%d\n", *p);
    free(p);
    return 0;
}
What you're solving

an output parameter that allocates