473,471 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what is this declaration?

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?
Jun 27 '08 #1
3 1116
12*******@gmail.com wrote:
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?
It needs more context.
What you've shown is neither a declaration nor an expression
nor any other C construct that I'm familiar with.

--
pete
Jun 27 '08 #2
On Jun 22, 4:31 pm, 123098...@gmail.com wrote:
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)();

Jun 27 '08 #3
On Jun 22, 9:31 am, 123098...@gmail.com wrote:
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.
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

70
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
15
by: M.Siler | last post by:
<HTML> <HEAD> <TITLE></TITLE> <SCRIPT> <!-- var factor_val = new Array(8,7) factor_val = 68.8 factor_val = 55
20
by: Sam | last post by:
Hi I'm learning to code with C++ and wrote some very simple code. I think it's consistent with every rule but always got compiling errors that I don't understand. The code include 5 files as...
10
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
9
by: Curious Student | last post by:
Some places till now, I've seen function prototypes within functions instead of in the global declaration space, which I thought was the way. I thought it was <I>only</I>: int myfunction(int,...
15
by: Greenhorn | last post by:
Hi, when a function doesn't specify a return type ,value what value is returned. In the below programme, the function sample()is returning the value passed to 'k'. sample(int); main() { int...
10
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and...
9
by: Michael Mair | last post by:
Hello, in C89 (at least in the last public draft), "3.6.2 Compound statement, or block", we have ,--- | Syntax | | compound-statement: | { ...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
10
by: tvnaidu | last post by:
I am using Three pthread functions below, I got ISO error, then I declared int variable called val123, then I assigned, but still I am getting error, any idea?. also I included pthread.h. compiling...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.