QP School

Full Version: Passing pointers to functions in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pointers can be passed to functions to modify the original data.

void increment(int *num) {
    (*num)++;
}

int main() {
    int x = 5;
    increment(&x);
    printf("x: %d\n", x); // Output: 6
    return 0;
}