How to Pass Pointer to Function in C Language

How to Pass Pointer to Function in C Language

pass a pointer to a function in C:

/*
Pass A Pointer to Function in C language
*/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>

void addOne(int* ptr) {
  (*ptr)++; // add 1
}

int main()
{
  int* p, i = 123;
  p = &i;
  addOne(p);

  printf("%d", *p); // 124
  return 0;
}
Sour‮.www:ec‬lautturi.com
Created Time:2017-08-29 09:47:42  Author:lautturi