Skip to content

Instantly share code, notes, and snippets.

@nickdesaulniers
Last active December 11, 2015 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickdesaulniers/4645944 to your computer and use it in GitHub Desktop.
Save nickdesaulniers/4645944 to your computer and use it in GitHub Desktop.
C Function Pointer Alternate Syntax
// compiled with:
// clang -Wall -Wextra function_pointers.c -o function_pointers
#include "stdio.h"
void usual_syntax (void (*fn) (int x)) {
puts("usual syntax start");
fn(1);
puts("usual syntax end");
}
void other_syntax (void fn (int x)) {
puts("other syntax start");
fn(2);
puts("other syntax end");
}
void hello (int x) {
printf("hello %d\n", x);
}
int main () {
puts("hello world");
usual_syntax(hello);
other_syntax(hello);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment