33 lines
696 B
C
33 lines
696 B
C
|
#include <stdio.h>
|
||
|
void a(int x)
|
||
|
{
|
||
|
printf("From function a: %d\n", x);
|
||
|
}
|
||
|
|
||
|
void b(int x)
|
||
|
{
|
||
|
printf("From function b: %d\n", x);
|
||
|
}
|
||
|
|
||
|
double c(char y)
|
||
|
{
|
||
|
printf("From function c: %c\n",y);
|
||
|
return 0.5;
|
||
|
}
|
||
|
|
||
|
int main(int argc, const char *argv[])
|
||
|
{
|
||
|
void (*func)(int);
|
||
|
// The two function calls below look the same but behave diffrent
|
||
|
// we are using a function pointer to change the function being called
|
||
|
// take a good look at the syntax, you are going to need it in the next exercise
|
||
|
func = b;
|
||
|
func(2);
|
||
|
func = a;
|
||
|
func(2);
|
||
|
|
||
|
// TODO: declare a function pointer for the function c and assigne c to it
|
||
|
|
||
|
// TODO: call c via function pointer with the argument 'c'
|
||
|
}
|