Skip to content

Instantly share code, notes, and snippets.

@radiofreejohn
Created March 18, 2011 23:51
Show Gist options
  • Save radiofreejohn/877044 to your computer and use it in GitHub Desktop.
Save radiofreejohn/877044 to your computer and use it in GitHub Desktop.
experimenting with function pointers, what a mess...
#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