0
    typedef struct list {
        int value;
        list *next;
    }list_t;

    void init(list_t *head) {
        head->next = NULL;
    }

Can you explain me that what difference between list and list_t?
I know declaration struct list list_t, but if I will declarate parametr list_t parametr, patametr.[...] I think this is the same effect as list parametr, parametr.[....] I don't understand what mean list *next it's the same like list_t *next ?

vmahth1
  • 203
  • 2
  • 9
  • 1
    In C++, there is no need to `typedef` a struct. C != C++, so in general you should not cross tag. – crashmstr Dec 14 '19 at 23:18
  • The linked answer is about C. In C++ there is no difference, so using a `typedef` makes no sense (`struct list {...};` is enough). – HolyBlackCat Dec 14 '19 at 23:20
  • therefore what mean ```list *next```? its the same what ```struct list *next``` or ```struct list_t *next```? – vmahth1 Dec 14 '19 at 23:23
  • @HolyBlackCat There is technically a difference, but it is too subtle to care about. – eerorika Dec 14 '19 at 23:33
  • @eerorika • the subtle difference in C++ being that `struct` "namespace" is a fallback after the regular namespace search comes up empty...? – Eljay Dec 14 '19 at 23:49

1 Answers1

0

In c, structs has their own namespace. list_t is an alias for the struct.

Dumbo
  • 13,555
  • 54
  • 184
  • 288