Function and Pointers

Passing pointers to the function

In a previous lesson, we discussed the following two ways of passing actual parameters to the formal parameters in the function:

  • Pass by value
  • Pass by reference

However, there is another way to pass arguments to the function that is passed by reference with a pointer parameter.

The function pointer parameter receives the address of the parameter. Then, it uses the dereference operator to access the value of the variable.

Basic syntax

The general syntax for passing a pointer to the function parameter is given below:

Get hands-on with 1200+ tech skills courses.