Problem of declaration in C language

wdliming's Avatar, Join Date: Sep 2010
Go4Expert Member
Today ,I have read the
<Expert C Programming,Deep C Secrets>,
Chapter 3.Unscrambling Declarations in C.
The author introduce the declaration of a little complicated function,then he left another exercise:
Code:
char *(*(c[10]))(int **p);
the answer is given at the of the Chapter 3

However, I am uncertain about the "c[10]",
the book is said:"c is an array[0...9] of pointer to a function returning a pointer-to-char",
I am thinking...
Is there a 10 function pointers ?
Could some master give me a example to show how to use the
char *(*(c[10]))(int **p);
in a C Program?
Thank you very much!

Last edited by coderzone; 17Mar2012 at 16:05..
PieterBeyens's Avatar, Join Date: Mar 2012
Newbie Member
Something like this?

Code:
#include <stdio.h>

char *(*(c[10]))(int **p);

char strf0[] = "function0";

char *f0(int **p)
{
	(void) p;
	return strf0;
}

int main(int argc, char** argv){
	c[0] = f0;
	printf("%s\n",f0(0));
	return 0;
}
Pieter Beyens
Bytelead
Scripting's Avatar, Join Date: Jun 2010
John Hoder
Quote:
Originally Posted by PieterBeyens View Post
Something like this?

Code:
#include <stdio.h>

char *(*(c[10]))(int **p);

char strf0[] = "function0";

char *f0(int **p)
{
    (void) p;
    return strf0;
}

int main(int argc, char** argv){
    c[0] = f0;
    printf("%s\n",f0(0));
    return 0;
}
Pieter Beyens
Bytelead
Yea, nice example.