>What is Foo here...
A pointer to a function that takes no arguments and returns a value of type int.
>i have used typedef but not like this..
Then follow the same rules you use to figure out any typedef:
A typedef uses the same syntax as a variable declaration, except instead of creating a variable with the specified name, it creates a type synonym with the specified name. So in the above typedef, foo_t is a synonym for int. Now let's declare a pointer to a function:
Code:
#include <stdio.h>
int do_something(void)
{
puts("foo");
}
int main()
{
int (*foo)(void);
foo = &do_something;
foo();
return 0;
}
That's tedious, so instead of declaring the pointer type directly, make it a typedef:
Code:
#include <stdio.h>
typedef int (*foo_t)(void);
int do_something(void)
{
puts("foo");
}
int main()
{
foo_t foo;
foo = &do_something;
foo();
return 0;
}
Problem solved as long as you recognize the type being typedef'd.