0
1.  struct node {
2.      char data;
3.      struct node* nxtPtr;
4.  }
5. 
6.  typedef struct node Node;
7.
8.  Node* front = NULL;
9.  Node* end = NULL;
10.
11. void enqueue(char userData)
12. {
13.     Node* temp = malloc(sizeof(Node));
14.     temp->data = userData;
15.     temp->nxtPtr = ???
16. }

I have kept the code to a minimum to try and avoid confusion. Eventually the variable end will point to a Node structure containing a data element and a Node pointer element. On line 15 I would like to de-reference end to access the value stored in nxtPtr from the current end Node. However the following line

temp->nxtPtr = *end->nxtPtr;

gives the following gcc error

  incompatible types when assigning to type ‘struct node *’ from type ‘struct node’
Philip Butler
  • 479
  • 1
  • 5
  • 13

1 Answers1

1

The A->B means "the B field of the struct that A points to", so you don't need the *.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
  • Thanks, I also just realised that I have made a misjudgment with the queue structure. I will ask for the question to be deleted. Thanks for your help – Philip Butler Oct 17 '16 at 21:32