0

While coding a linked list I came across this confusing concept of

struct Node *next;
struct Node* next;

If there is a difference in the memory management or in any other way between the two kindly explain it diagrammatically!

unwind
  • 391,730
  • 64
  • 469
  • 606
Oswald Vinny
  • 53
  • 1
  • 10
  • 1
    If not, you still need a diagram? – red0ct Jun 30 '16 at 12:12
  • These are the same: during translation the spaces are eventually removed (the declaration becomes a token sequence containing the tokens `struct`, `Node`, `*`, `next` and `;`). You could skip the space entirely since `*` will work as separating tokens (ie `struct Node*next;). – skyking Jun 30 '16 at 12:17
  • haha..obviously no if not I dnt need the diagram.! – Oswald Vinny Jun 30 '16 at 12:20
  • Both are same, though I would recommend you to learn the basics tokens, separators, c semantics and grammar and all basic stuffs before moving on to structures and linked list. – Pankaj Prakash Jun 30 '16 at 12:35

1 Answers1

1

Those two declarations are equivalent. Both declare next to be of type struct Node *.

dbush
  • 205,898
  • 23
  • 218
  • 273