Skip to content

Instantly share code, notes, and snippets.

@m3talsmith
Last active January 2, 2016 08:39
Show Gist options
  • Save m3talsmith/8278184 to your computer and use it in GitHub Desktop.
Save m3talsmith/8278184 to your computer and use it in GitHub Desktop.
Testing callbacks in c
#include <stdio.h>
void say(char *string[]) {
printf("%s\n", *string);
}
int add(int a, int b, void (*callback)(char *string[])) {
int sum = a + b;
char* mesg;
asprintf(&mesg, "%d + %d = %d", a, b, sum);
callback(&mesg);
return sum;
}
int main() {
add(2, 2, &say);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment