2

I am a newbie in C and I stumbled on this c-structure:

typedef struct
{
   int dog;
   int cat;
} FOO;

typedef struct
{
   int  id;
   FOO* pRow[0]
} BAR;

I know basic c and c++ but I have no idea the motivation of the following line: "FOO* pRow[0]".

If the author wants to define a pointer to an array of FOO, then he/she should just define it as "FOO* pROW", right? Why does pROW[0] stands for in this case then?

Please enlighten me. Thanks!

unki
  • 964
  • 6
  • 10

1 Answers1

-2

the pRow is an array of pointers. the first element ,pRow[0] is pointing to a FOO struct.

if you write FOO* pRow, then the pRow is simply one pointer

Chrim
  • 100
  • 8
  • Not really, because you can allocate it to N sizeof(FOO), and then it would't be one pointer. – Ryan Sep 03 '15 at 02:38