This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Array of pointers to structures

I am getting an error 199 "left side of '->' requires a struct/union pointer. I'm not entirely sure why. Maybe it's obvious, but I've been looking at this code for too long:

struct test_struct
{
 U8  blah;
 U16 more_blah;
};

// Here's an array of these
struct test_struct example[2] =
{
 { 1, 2 },
 { 3, 4 }
};

// Now I just want to point to these

struct test_struct * p[2];

// Somewhere they get initialized
...
p[0] = &example[0];
p[1] = &example[1];
...

// Later I want to use the pointers:

U8  i;
U16 j;

  i = p[0]->blah;
  j = p[0]->more_blah;


Here's where I get the error. For some reason it doesn't think that "p[0]" is a pointer to a struct. I'm not sure why.
Any ideas?

Thanks!

Parents Reply Children
No data