0

In lcthw ex32, functions are definde as:

List *List_create();
void List_destroy(List * list);
void List_clear(List * list);
void List_clear_destroy(List * list);

I understood the basic logic, but have no idea what does List * list means. Shouldn't it be List *list to specify it as a List struct? Why it has to be List * list?

the busybee
  • 10,755
  • 3
  • 13
  • 30
Zewei Song
  • 521
  • 2
  • 6
  • 13
  • 1
    It doesn't matter: `List* list` or `List * list` or `List *list` but IMO prefer the last. – Weather Vane Apr 14 '22 at 09:54
  • Whitespace is only mandatory if its missing will lead to other language tokens, like concatenated symbols, or in expressions like `v = 3 + +i;`. Else it is optional, use it as you see fit or the project's coding guide requests. – the busybee Apr 14 '22 at 09:57
  • I prefer the first because it makes it clearer to me that `list` is a `List*` , i.e. a "Pointer to a `List`", but opinions differ here, as you see :) – CherryDT Apr 14 '22 at 09:57
  • 1
    I prefer the last because it makes it clearer to me that `List* a, b, c;` only defines *one* pointer variable. This is clearer with `List *a, b, c;` and I stick to the same convention in other circumstances. – Weather Vane Apr 14 '22 at 09:59

0 Answers0