C: Ponteiro para função

From AdonaiMedrado.Pro.Br
Revision as of 01:43, 17 April 2009 by Adonaimedrado (Talk | contribs) (New page: <code lang="c"> #include <stdio.h> void ola(void) { printf("Olá.\n"); } void bomdia(void) { printf("Bom dia.\n"); } void tchau(void) { printf("Tchau.\n"); } void voltelogo(void) { ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <stdio.h>
 
void ola(void)
{
	printf("Olá.\n");
}
 
void bomdia(void)
{
	printf("Bom dia.\n");
}
 
void tchau(void)
{
	printf("Tchau.\n");
}
 
void voltelogo(void)
{
	printf("Volte logo.\n");
}
 
int executar(void (*f)(void))
{
	(*f)();
}
 
int main(void)
{
	void (*p)(void);
 
	executar(ola);
	executar(bomdia);
	executar(tchau);
 
	p=voltelogo;
	executar(p);
	return 0;
}