Last active
October 29, 2019 14:48
-
-
Save rrmhearts/ee336fdc1cb54f8473aad4bc6bef7641 to your computer and use it in GitHub Desktop.
Passing a Function in C
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
#include <stdio.h> | |
void printNumber(int nbr) | |
{ | |
printf("%d\n", nbr); | |
} | |
void myFunction(void (*f)(int)) | |
{ | |
for(int i = 0; i < 5; i++) | |
{ | |
(*f)(i); | |
} | |
} | |
int main(void) | |
{ | |
myFunction(printNumber); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment