Pergunta

I have this type of definition

int (*af[10])(int , *a[10][10])(int,int)

and I had to "translate" it just like "this is pointer to function array size of 10" etc etc. I think that there is a mistake here, cause *a[10][10] doesn't have a definition type. Is this correct? Or this line can be translated properly?

Thanks in advance


Finally I found that the correct definition should be like this

int (*af[10])(int ,int (*a[10][10])(int,int))

which is correct and makes sense.

Foi útil?

Solução

This is not a valid C declaration. First, the type of a is missing. But worse than that, it's as if (*af[10])(int , *a[10][10]) was returning a function (which is impossible).

Maybe you meant:

int (*(*af[10])(int , int *a[10][10]))(int,int)

Which would make af an array of 10 pointers to function receiving int and an array of 10 arrays with 10 pointers to int, and returns a pointer to function receiving two ints and returning an int.

EDIT:

Looks like the correct line is:

int (*af[10])(int ,int (*a[10][10])(int,int))

This makes af an array of 10 pointers to function receiving 2 parameters and returning int. The first parameter is an int, and the second is a multi-dimensional array (10x10) or pointers to function receiving 2 ints and returning an int.

In the future, you might want to check out cdecl.org to confirm your guess.

Outras dicas

I think that af is actually an array:

af[10]

The array contains pointers:

*af[10]

Those are pointers to functions:

int (*af[10])(...)

And the argument list has a syntax error, probably the comma after int is there by mistake:

int (*af[10])(int *a[10][10])

And the rest of the line is rubbish.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top