title: Why is the process being terminated after my code runs? Process returns 255
body: <p>I am new to pointers and creating linked lists. The code is only a part of the entire thing. I tried to make this part simpler for testing and debugging but I still can figure it out. Can someone help me figure out with the process is being terminated after it executes the given code?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  
  #define SPADE "SPADE"
  #define CLUB "CLUB"
  #define DIAMOND "DIAMOND"
  #define HEART "HEART"
  
  typedef struct Card{
      int value;
      char suit[10];
  }Card;
  
  typedef struct BagNode {
      Card* card;
      struct BagNode* next;
  }BagNode;
  
  int main() {
  
      BagNode* head = NULL;
      BagNode* tail = NULL;
  
      const char* suit = SPADE;
      int value = 6;
  
  
      if(tail == NULL)
      {
          printf("add funct works\n");
          BagNode* newNode = (BagNode*)malloc(sizeof(BagNode));   // allocate space
          newNode-&gt;card-&gt;value = value;                                  // assign value
          strcpy(newNode-&gt;card-&gt;suit, suit);                      // assign value
          head = newNode;
          tail = newNode;
          printf("added cards\n");
      }
      else{
          BagNode* newNode = (BagNode*)malloc(sizeof(BagNode));   // allocate space
          newNode-&gt;card-&gt;value = value;                                  // assign value
          strcpy(newNode-&gt;card-&gt;suit, suit);                      // assign suit
          tail-&gt;next = newNode;
          tail = newNode;
      }
  }
  </code></pre>
  
  <p>This is what the output looks like:</p>
  
  <pre><code>add funct works
  added cards
  
  Process returned 255 (0xFF)   execution time : 6.898 s
  </code></pre>
  
  <p>Why is it returning 255? </p>
  
  <p>Any direction would be greatly appreciated!</p>
  
  <p>**note: I'm writing in C</p>