[net.lang.c] Function returning pointer to function

ark@alice.UUCP (Andrew Koenig) (07/20/85)

> char cd[2] = {'c','d'};
> char (*pcd)[] = cd;
> /* "junk.c", line 55: warning: illegal pointer combination        */

> /* What is it that the compiler (4.1 BSD) doesn't like?          */

Well, let's see.  You are saying that pcd is a thing such that if
you dereference it and the subscript it, you get a char.  In other words,
pcd is a pointer to a pointer to a char.  cd is a pointer to char,
so you can't assign it to pcd.

Now, if you had said:

char cd[2] = {'c','d'};
char *pcd[] = {cd};

you are now saying that you can subscript pcd and then dereference
it to get a char.  Thus pcd is an array of pointers to chars; the
length of the array is given by the initialization to be 1.