title: Dynamic memory allocation for node in linked list
body: <p>Why when i have to declare a pointer to a node (head) I also have to allocate memory with <code>malloc</code> or <code>calloc</code> for it? I saw that the code that generate a list (not imported here) works well also without allocate memory for it and just declaring <code>node *head</code>.</p>
  <pre><code>typedef struct str_node{
      int data;
      struct str_node *next;
  }node;
  
  int main(){
  
      node *head;
  
      head = (node*) malloc(sizeof(node));
      head = NULL;
  </code></pre>
  <p>And why when I allocate memory like above i have to write <code>(node*)</code>? Isn't it already allocated to a struct node since I'm doing it on head? What is the meaning of that line of code exactly? Moreover when I write <code>head = NULL</code> am I set the address of the pointer head to NULL or what?</p>