pointer as parameter c code example
Example 1: c function pointer in argument
void f(void (*a)()) {
a();
}
void test() {
printf("hello world\n");
}
int main() {
f(&test);
return 0;
}
Example 2: how to use a pointer as a parameter in c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void add(int* a, int* b, int* c)
{
*c = *a + *b;
}
int main()
{
int a, b, c;
a = 3;
b = 5;
add(&a, &b, &c);
printf("%d", c);
}