S
Steve Lambert
Hi,
I'd be grateful if someone could clarify this for me. In the linked list
structure my intention is to declare an array of length 3 containing
pointers to node
eg. Node *Iterators[3]
The compiler seems to interpret this as a pointer to an array of 3 nodes
instead. This interpretation ensures that the second assigment to mynode
below fails compilation with the given message.
Could someone explain to me how to correctly declare an array of length 3
containing pointers to node
cheers
#include <stdio.h>
typedef struct Node
{
void *Data;
struct Node *Next;
struct Node *Previous;
} Node;
/* structure to represent a linked list */
typedef struct LinkedList
{
Node *Head; /* start of linked list */
Node *Tail; /* end of linked list */
long NumberOfNodes;
short NumberOfIterators;
Node *Iterators[3];
} LinkedList;
LinkedList *mLinkedLists[2];
void main()
{
Node *mynode;
LinkedList *LL=NULL;
LL = mLinkedLists[0];
mynode = LL->Iterators[0]; <- this compiles
mynode = LL->Iterators; <- this doesn't : cannot convert from 'struct Node
*[3]' to 'struct Node *
printf("out\n");
}
I'd be grateful if someone could clarify this for me. In the linked list
structure my intention is to declare an array of length 3 containing
pointers to node
eg. Node *Iterators[3]
The compiler seems to interpret this as a pointer to an array of 3 nodes
instead. This interpretation ensures that the second assigment to mynode
below fails compilation with the given message.
Could someone explain to me how to correctly declare an array of length 3
containing pointers to node
cheers
#include <stdio.h>
typedef struct Node
{
void *Data;
struct Node *Next;
struct Node *Previous;
} Node;
/* structure to represent a linked list */
typedef struct LinkedList
{
Node *Head; /* start of linked list */
Node *Tail; /* end of linked list */
long NumberOfNodes;
short NumberOfIterators;
Node *Iterators[3];
} LinkedList;
LinkedList *mLinkedLists[2];
void main()
{
Node *mynode;
LinkedList *LL=NULL;
LL = mLinkedLists[0];
mynode = LL->Iterators[0]; <- this compiles
mynode = LL->Iterators; <- this doesn't : cannot convert from 'struct Node
*[3]' to 'struct Node *
printf("out\n");
}