Skip to content

Instantly share code, notes, and snippets.

@suzukiplan
Created August 30, 2018 06:11
Show Gist options
  • Save suzukiplan/094e0cd7f64094e9a5662999274666da to your computer and use it in GitHub Desktop.
Save suzukiplan/094e0cd7f64094e9a5662999274666da to your computer and use it in GitHub Desktop.
Callback example for C
#include <stdio.h>
void functionWithCallback(void(*callback)(int, int)) {
callback(1234, 5678);
}
void callback(int a, int b) {
printf("a=%d, b=%d\n", a, b);
}
int main() {
functionWithCallback(callback);
return 0;
}
@suzukiplan
Copy link
Author

$ clang callback_on_c.c 
$ ./a.out
a=1234, b=5678
$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment