473,385 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Who can explain the sentence for me?

Hi,
I meet a sentence:
------------------------------------------------
struct intNode *(*fpt[])(void)=
{createList, inNode, delNode,revNode,NULL};
-------------------------------------------------
The "createList","inNode","delNode","revNode" are functions.
I'm puzzled by the c sentence.
Who can explain it for me?
Thanks!
Nov 14 '05 #1
8 1295
"huhu" <as***@public.gz.cn> wrote in message
news:c1**********@mail.cn99.com...
Hi,
I meet a sentence:
------------------------------------------------
struct intNode *(*fpt[])(void)=
{createList, inNode, delNode,revNode,NULL};
-------------------------------------------------
The "createList","inNode","delNode","revNode" are functions.
I'm puzzled by the c sentence.
Who can explain it for me?


an array of function pointers is declared and initialized. The functions
have a struct intNode * as return value and expect no parameters.
Nov 14 '05 #2

"huhu" <as***@public.gz.cn> a écrit dans le message de
news:c1**********@mail.cn99.com...
Hi,
I meet a sentence:
------------------------------------------------
struct intNode *(*fpt[])(void)=
{createList, inNode, delNode,revNode,NULL};
-------------------------------------------------
The "createList","inNode","delNode","revNode" are functions.
I'm puzzled by the c sentence.
Who can explain it for me?
Thanks!

fpt is a table of functions that return a pointer to an "intNode" and
receive no arguments. This table contains 5 positions, the first four are
filled with the
respective functions, and the fifth position is NULL.

C can be very concise. More probably than is needed... :-)

Nov 14 '05 #3
"huhu" <as***@public.gz.cn> wrote in message
Who can explain it for me?

*cdecl* (C declaration parser) can explain it for you.
Nov 14 '05 #4
On Sun, 29 Feb 2004 20:16:43 +0800, "huhu" <as***@public.gz.cn> wrote:
Hi,
I meet a sentence:
------------------------------------------------
struct intNode *(*fpt[])(void)=
{createList, inNode, delNode,revNode,NULL};
-------------------------------------------------
The "createList","inNode","delNode","revNode" are functions.
I'm puzzled by the c sentence.
Who can explain it for me?
Thanks!

fpt is a 1-D array of unspecified quantity of pointer to function
(each of the functions pointed to be elements of the array)
taking no parameters
returning pointer to struct intNode

The array is initialized with five values (and the unspecified
quantity mentioned above is now determined to be five):
the address of the function createList
the address of the function inNode
....
the value of the NULL pointer constant
<<Remove the del for email>>
Nov 14 '05 #5
In <c1**********@news-reader3.wanadoo.fr> "jacob navia" <ja***@jacob.remcomp.fr> writes:

"huhu" <as***@public.gz.cn> a écrit dans le message de
news:c1**********@mail.cn99.com...
Hi,
I meet a sentence:
------------------------------------------------
struct intNode *(*fpt[])(void)=
{createList, inNode, delNode,revNode,NULL};
-------------------------------------------------
The "createList","inNode","delNode","revNode" are functions.
I'm puzzled by the c sentence.
Who can explain it for me?
Thanks!

fpt is a table of functions that return a pointer to an "intNode" and
receive no arguments. This table contains 5 positions, the first four are
filled with the
respective functions, and the fifth position is NULL.

C can be very concise. More probably than is needed... :-)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That's one of the reasons it comes with the typedef thing :-)

A single typedef could turn that monster declaration into something
that even a beginner could read.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #6
huhu <as***@public.gz.cn> wrote:
Hi,
I meet a sentence:
------------------------------------------------
struct intNode *(*fpt[])(void)=
{createList, inNode, delNode,revNode,NULL};
-------------------------------------------------
The "createList","inNode","delNode","revNode" are functions.
I'm puzzled by the c sentence.
Who can explain it for me?
Thanks!


There is no such thing as a sentence in C.

'fpt' is defined as an array of pointers to functions which take
no arguments and return a pointer to 'struct intNode'. It is
subsequently initialized with what are probably pointers to
functions that meet these critera.

I recommend that you consult your favorite C book.

--
Alex Monjushko (mo*******@hotmail.com)
Nov 14 '05 #7
"huhu" <as***@public.gz.cn> wrote in message news:<c1**********@mail.cn99.com>...
Hi,
I meet a sentence:
------------------------------------------------
struct intNode *(*fpt[])(void)=
{createList, inNode, delNode,revNode,NULL};
-------------------------------------------------
The "createList","inNode","delNode","revNode" are functions.
I'm puzzled by the c sentence.
Who can explain it for me?
Thanks!


fpt -- fpt
fpt[] -- is an array
*fpt[] -- of pointers
(*fpt[])() -- to functions
(*fpt[])(void) -- taking no parameters
*(*fpt[])(void) -- returning pointers
struct intNode *(*fpt[])(void) -- to struct intNode

and the prototypes for the functions in the array are

struct intNode *createList (void);
struct intNode *inNode (void);
struct intNode *delNode (void);
struct intNode *revNode (void);

Calling fpt[0]() is the same as calling createList(), fpt[1]() is the
same as calling inNode(), etc.
Nov 14 '05 #8
Thank you very much!
Nov 14 '05 #9

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

Similar topics

1
by: Christian Buck | last post by:
Hi, i'm writing a regexp that matches complete sentences in a german text, and correctly ignores abbrevations. Here is a very simplified version of it, as soon as it works i could post the...
13
by: C++fan | last post by:
The following code is for list operation. But I can not understand. Could anyone explain the code for me? /* * List definitions. */ #define LIST_HEAD(name, type) struct name { type...
3
by: Jason luo | last post by:
Hi all, In c99-standard page 52,there is a sentence about void,as below: If an expression of any other type is evaluated as a void expression, its value or designator is discarded. I don't...
3
by: Jan Nielsen | last post by:
Hi I am working with rowfilters in dataviews. I would like to filter for empty fields (= null value in the database) I found this sentence on msdn: **************** To return only those columns...
40
by: dev_cool | last post by:
hello everybody, i'm a new member of this group, this is my first ever post. i've found a c program that prints prime numbers through an infinite loop. But I really don't understand the code....
6
by: mike | last post by:
Hello, I am trying to write some code to parse a sentence and hyperlink just the words in it. I used Aaron's code from an earlier question as a start. So far, all the code does below is...
4
by: wohast | last post by:
Hi, I'm stuck at the very beginning of my current assignment. I just need a little help getting started, and then I know how to do everything else. ask user: "Please enter your name followed by...
19
by: fellya | last post by:
Hi, i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python. I've tried to write a simple program that can display a sentence. now my...
1
by: fellya | last post by:
Hi, i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python. I've tried to write a simple program that can display a sentence. now my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.