Alex Rivera | Logout

C negative array index

Asked 2010-10-24T00:46:28.597
10

this is my struct :

struct Node {
    struct Node* data;
    struct Node* links[4];
}

assuming there is no padding, does Node->links[-1] guaranteed to be pointing on Node::data ?

Edit
Report

1 Answer

3

A union might help you here. Something like this:

struct Node {
  union {
    Node *data;
    struct {
      Node *lnk[5];
    } links;
  }
}
answered 2010-10-24T01:19:31.253

Your Answer