Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Function Pointer
#include <stdio.h>
int sum(int a, int b)
return a+b;
void hello_name(char *name)
printf("Hello %s", name);
int main()
int (*ptr)(int, int);
ptr = &sum; // can omit '&'
printf("sum is = %d\n", (*ptr)(4,5)); // only 'ptr' will do too
void (*ptr2)(char*);
ptr2 = hello_name;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment