QP School
Passing pointers to functions in C - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32)
+--- Thread: Passing pointers to functions in C (/showthread.php?tid=5093)



Passing pointers to functions in C - Qomplainerz - 07-25-2023

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;
}