Created
March 18, 2011 23:51
-
-
Save radiofreejohn/877044 to your computer and use it in GitHub Desktop.
experimenting with function pointers, what a mess...
This file contains hidden or 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 printnnl(char *); | |
void printnl(char *); | |
void printgeneric(void (*printfunc)(char *), char *str); | |
void printgeneric(void (*printfunc)(char *), char *str) | |
{ | |
(*printfunc)(str); | |
} | |
void printnnl(char *str) | |
{ | |
printf("%s", str); | |
} | |
void printnl(char *str) | |
{ | |
printf("%s\n",str); | |
} | |
int main() | |
{ | |
printgeneric(printnnl, "hi"); | |
printgeneric(printnl, " world"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment