473,406 Members | 2,312 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,406 software developers and data experts.

A slightly more complicated function pointer declaration

char * const * (*fn)(void);

Seems rarther confusing to me, becuase of the way const can be used, like
this:

const char * a; /* pointer to const char */
char const * a; /* pointer to const char */
char * const a; /* const pointer to char */

I would guess that function declaration means this:

A pointer to a function returning a pointer to a const pointer to a char. Is
there a good way of reading things such as this?
Nov 13 '05 #1
3 6220
Jason wrote:
char * const * (*fn)(void);

Seems rarther confusing to me, becuase of the way const can be used, like
this:

const char * a; /* pointer to const char */
char const * a; /* pointer to const char */
char * const a; /* const pointer to char */

I would guess that function declaration means this:

A pointer to a function returning a pointer to a const pointer to a char.
Is there a good way of reading things such as this?


When I am tired I use cdecl:

qcd:~$ cdecl
Type `help' or `?' for help
cdecl> explain char * const * (*fn)(void);
declare fn as pointer to function (void) returning pointer to const pointer
to char
cdecl>

Tobias.

--
unix http://www.faqs.org/faqs/by-newsgrou...rogrammer.html
clc http://www.eskimo.com/~scs/C-faq/top.html
fclc (french): http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #2

"Jason" <@> wrote in message news:3f0ddabc@shknews01...
char * const * (*fn)(void);

Seems rarther confusing to me, becuase of the way const can be used, like
this:

const char * a; /* pointer to const char */
char const * a; /* pointer to const char */
char * const a; /* const pointer to char */

I would guess that function declaration means this:

A pointer to a function returning a pointer to a const pointer to a char. Is there a good way of reading things such as this?


Any hints?
Nov 13 '05 #3

"Jason" <@> wrote in message news:3f0fd299@shknews01...
....
Any hints?

....

Sorry, newsfeed very slow.
Nov 13 '05 #4

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

Similar topics

7
by: johny smith | last post by:
Can someone please explain to me the difference between these two: function1( const int a) function2( int const a) Both seemed to compile, but what is the difference between the two above....
3
by: Dennis Chang | last post by:
Hi all, I was reading about function pointers and came across something which intrigued me. K&R2 calls qsort (pg.119) within main as so: qsort( (void **) lineptr, 0, nlines-1, (int (*) (void...
5
by: Cancerbero | last post by:
Hi (first, excuse me for my bad english) As I know, the semantics for typedef is: typedef A B; I think this makes B a synonym of A, where A is an existing data type. Is that right? Based...
51
by: Richard Hengeveld | last post by:
Hi all, I'm trying to understand how pointers for function parameters work. As I understand it, if you got a function like: void f(int *i) { *i = 0; }
3
by: robin liu | last post by:
What's the difference between these two declarations ? 1) typedef void (*pf)(void); 2) typedef void f(void); the first declaration is define a function pointer, what is the second ? define a...
12
by: Googy | last post by:
Hi!! Can any one explain me the meaning of following notations clearly : 1. typedef char(*(*frpapfrc()))(); frpapfrc f; 2. typedef int (*(arr2d_ptr)()); arr2d_ptr p; 3. typedef int...
3
by: asit | last post by:
Are the following declaration correct ?? int *p// p is a pointer to integer int *p// p is an array of integer pointers int (*p)// p is a pointer to an integer array int *p()// p is a...
26
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
20
by: MikeC | last post by:
Folks, I've been playing with C programs for 25 years (not professionally - self-taught), and although I've used function pointers before, I've never got my head around them enough to be able to...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.