/*
 * A simple program that gives an example of a function pointer.
 *
 * Steve Shah (sshah@planetoid.org)
 *
 * Compiles on FreeBSD with: gcc -Wall -ansi -pedantic -g prog.c -o prog
 * with no warnings. Not tested with any other OS although I don't
 * imagine there being any problems...
 *
 */

#include <stdio.h>
#include <string.h>

void printint (int *x)
{
	printf ("%d\n", *x);
	return;
}

void printstr (const char *str)
{
	printf ("%s\n", str);
	return;
}


void myfunction(void *a, void (*print)(void *))
{
	print(a);
}


int main ()
{
	char *mystr="Hello";
	int mynum=5;

	myfunction(mystr,(void (*)(void*))printstr);
	myfunction(&mynum,(void (*)(void*))printint);

	return 0;
}




