what is this declaration?

1

1230987za

Hi,

I was reading a post about how to learn C programming and someone
mentioned this, *(int f()) in a struct. It is not in any C code, I
guess the guy was showing that there are some tricky part in C.

It does look tricky to me, what does it mean?

Is the following correct?

f is a function; the function returns an integer; this integer is de-
referenced just like a function pointer.

Can someone show me an example usage of such declaration?
 
O

Old Wolf

I was reading a post about how to learn C programming and someone
mentioned this, *(int f()) in a struct. It is not in any C code, I
guess the guy was showing that there are some tricky part in C.

This is not a valid declaration ; perhaps you
are remembering it wrongly.
f is a function; the function returns an integer; this integer is de-
referenced just like a function pointer.

Integers cannot be dereferenced.

A function returning int would be:
int f();
which cannot occur in a struct definition.

A pointer to function returning int would be:
int (*f)();
 
R

rahul

Hi,

I was reading a post about how to learn C programming and someone
mentioned this, *(int f()) in a struct. It is not in any C code, I
guess the guy was showing that there are some tricky part in C.

It does look tricky to me, what does it mean?

Is the following correct?

Does not look like it can be correct in any context.
f is a function; the function returns an integer; this integer is de-
referenced just like a function pointer.

That does not make any sense at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top