• 02-26-2011
nutzu2010
What do the following statements?

Code:

`int f1(int a, double (*f)(float *b));`
f1 is a function that returns an integer and has two parameters:first is a int and the second is an pointer to a function than returns an double and than has a parameter:a pointer to a float.

Code:

`int f2(int a, double f(char c), int (*g)(int d, int *e));`
f2 is function than returns an integer and has three parametrers:a integer,a function f than returns a double and has a parameter(a char), a pointer to a function than returns a int and has two parameters:a int and a pointer to int.

Code:

`float *f3(double *a, int * (*f)(double));`
f3 is a function than return a pointer to a float and has two parameters: a pointers to a double,a pointer to a function than returns a pointer to a int whith a parameter(a double)

Code:

`double (*fc)(int a, float ff(void));`
fc is a pointer to a function than returns a double and has two parameters:an int,a function than returns a float and has non parameters.

Code:

`int *(*fd)(float *a, double *f(int *d));`
fd is a pointer to a function than returns a pointer to a int and has two parameters:a pointer to a int,a function than returns a pointer to a double and has a pointer to a int
• 02-26-2011
Just looked at f1, and the error is that the function f parameter is a pointer to float, not a pointer to double.

You've got the right idea, however.
• 02-26-2011
nutzu2010
first time I've written on a sheet, After that I wrote on the computer...Maybe that's why I wrote wrong

I want to learn pointer to functions
If these answers are correct you can I still put a few questions?
• 02-26-2011
f2 looked good, watch your spelling of parameters though. (doesn't bother me, but it might bother your boss or instructor).

Sure, if it's on this topic, ask away! ;)

If it's on a different topic, please start up a new thread so it gets the attention it deserves.
• 02-26-2011
nutzu2010
ok,f2 is correct,but f3,fd,fc ?

Quote:

Sure, if it's on this topic, ask away!
no,i wanna - you ask me any questions about "pointer to functions"(outside structures)
• 02-26-2011
What's wrong with this one?
Code:

Code:

`int *(*fd)(float *a, double *f(int *d));`
Quote:

fd is a pointer to a function than returns a pointer to a int and has two parameters:a pointer to a int,a function than returns a pointer to a double and has a pointer to a int
• 02-26-2011
Bayint Naung
cdecl
Can be helpful tools. Of course, it's still important to understand... the concept.
The only thing you need to take note is
Code:

```  void foo( double f(double) );   is the same as   void foo( double (*f)(double)) ;```
• 02-26-2011
nutzu2010
Quote:

fd is a pointer to a function than returns a pointer to a int and has two parameters:a pointer to a float,a function than returns a pointer to a double and has a pointer to a int
now is correct?
• 02-26-2011
nutzu2010
Quote:

Originally Posted by Bayint Naung
cdecl
Can be helpful tools. Of course, it's still important to understand... the concept.
The only thing you need to take note is
Code:

```  void foo( double f(double) );   is the same as   void foo( double (*f)(double)) ;```

sow
Quote:

double f(double)
is a pointer to function?

cdecl is only for linux?
• 02-26-2011