no********@gmail.com wrote:
recently I attended a test on C where I was asked to declare the
following declarations in one line.
void ** ( *p )(int *, char *);
int *a;
I worked out the answer
we can write the declaration as
void **(*p)(int *,char *), *a;
You changed the declaration. You were asked to declare a as pointer to
int, according to your own original post, and your solution declares it
as pointer to void.
now later when we use a we can typecast it to int *.
It will work without typecasting as well.
I tried it out. it works.
No, it doesn't. The original declaration allows you to write *a = 0;.
Your modified declaration does not. It's possible that what you wrote
is the intended solution, but if that's the case, the question was
simply plain wrong.