Last active
December 11, 2015 19:08
-
-
Save nickdesaulniers/4645944 to your computer and use it in GitHub Desktop.
C Function Pointer Alternate Syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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