title: member access within null pointer of type 'struct structVarable'
body: <pre><code>struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2)
  {
      struct ListNode *temp1, *temp2, *temp3, *start;
      temp3 = (struct ListNode*)malloc(sizeof(struct ListNode));
      temp3-&gt;val = 0;
      temp3-&gt;next = NULL;
  
      if (!temp3)
          exit(0);
  
      temp1 = l1;
      temp2 = l2;
      int val, v1, v2, v3;
  
      while (temp1 != NULL &amp;&amp; temp2 != NULL)
      {
          v1 = temp1-&gt;val;
          v2 = temp2-&gt;val;
          val = v1 + v2;
  
          if (val &gt; 9)
          {
              (temp3-&gt;val) = (val - 10); //error here
              temp1 = temp1-&gt;next;
  
              (temp1-&gt;val) = ((temp1-&gt;val) + 1);
          }
          else
              (temp3-&gt;val) = val;
  
          if (start == NULL)
              start = temp3;
  
          temp3 = temp3-&gt;next;
          temp1 = temp1-&gt;next;
          temp2 = temp2-&gt;next;
      }
  
      while (temp1 != NULL)
      {
          (temp3-&gt;val) = (temp1-&gt;val);
          if (start == NULL)
              start = temp3;
          temp3 = temp3-&gt;next;
          temp1 = temp1-&gt;next;
  
  
      }
  
      while (temp2 != NULL)
      {
          (temp3-&gt;val) = (temp2-&gt;val);
          if (start == NULL)
              start = temp3;
          temp3 = temp3-&gt;next;
          temp2 = temp2-&gt;next;
      }
  
      return start;
  }
  </code></pre>
  
  <p>There's an error in this line of code (line:31 <code>(temp3-&gt;val)=(val-10);</code>)
  I've tried adding these lines of code after allocating memory for <code>temp3</code> (<code>temp3-&gt;val=0; temp3-&gt;next=NULL;</code>), but no use.</p>