Skip to content

Instantly share code, notes, and snippets.

@tosone
Last active August 16, 2019 03:22
Show Gist options
  • Save tosone/1bd7e930b4ddcf7e2840514067ae8ff0 to your computer and use it in GitHub Desktop.
Save tosone/1bd7e930b4ddcf7e2840514067ae8ff0 to your computer and use it in GitHub Desktop.
[Callback in C] #C
#include <stdio.h>
typedef void (*callback_t)(char *);
void callback_test(char *str) {
printf("%s\n", str);
return;
}
void callback_main(callback_t cb) {
cb("hello");
return;
}
int main() {
callback_main((callback_t)(&callback_test));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment