Values & References4 / 18
Up next

Pass by pointer mutates

#include <stdio.h>

void double_it(int *n) {
    *n *= 2;
}

int main(void) {
    int x = 5;
    double_it(&x);
    printf("%d\n", x);
    return 0;
}
What you're solving

a pointer reaches the caller's variable