Passing Pointers as Function Argument in C

In C language we can pass the pointer as an function argument. To do so we have to declare the function parameter as a pointer type.
void MyFunc(int *ptr);
And also note that at the time of function call we need to put the address of ( & ) operator within the argument provided to the function.
Myfunc(&arg);
Example :
#include<stdio.h>

void printNum(int *ptr);

int main() {
  int n = 10;
  printNum(&n);
  return 0;
}

void printNum(int *ptr) {
  printf("%d\n", *ptr);
}
Output :

10


Next Topic :