From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Passing pointers to functions

Passing pointers to functions

- [Instructor] When you pass a pointer to a function, you're passing an address either directly or as a memory location stored in a pointer. A function that accepts a pointer as input, accepts an address. In this exercise file, the doubler function consumes the address of an integer variable, an integer pointer referenced as alpha within the function. You see the contents of the address are manipulated. The asterisk operator dereferences the address. In this instance, the integer value at location alpha is doubled. Nothing is returned from this function, it's a void data type. Nothing needs to be returned as memory is manipulated directly. In the main function, the address of variable a is passed at line 13. Only the address, not the value, which is assigned is 25, run. The value is modified without being returned. That's because the address passed references the value, which is modified in memory. At line 13, the address of variable a is passed to the function. The ampersand operator…

Contents