I'm new to these forums (and pretty new to C), so first I would like to say Hi to everybody.

I have come here seeking help with a linked list stack implementation. Basically I am trying to implement a program that generates a stack of regular playing cards ie: 52 cards hearts spades etc. It then shuffles these cards and then deals them out into two seperate piles of equal amounts. This is for a school assignment with focus on ADTs (something I am still trying to get my head around :S).

The code compiles without any errors, however I get a segmentation fault whenever I try to run the executable. I have narrowed down when the fault ccurs and it seems to be caused by the line: strcpy(newCard->suit, suit); which is in the init_card function of deck.c. I understand that segmentation faults occur when the program attempts to write to memory when it does not have permission. My understanding of malloc() is that memory allocated by it remains until freed regardless of which function the program is in.

I apologise for the amount of code included. If anybody can offer any help at all it would be much appreciated. Thanks.

Code:
[main.c]
#include <stdlib.h>
#include <stdio.h>
#include "main.h"
#include "deck.h"
#include "stack.h"


int main (int argc, char **argv)
{
   int i;
   // Generate a deck of cards and shuffle
   char *suit[] = {"Diamonds", "Hearts", "Clubs", "Spades"};
   card deck[52];

   fill_deck (deck, suit);
   shuffle (deck);

   // Initialise stack pointers
   card *p1top, *p2top, *p1bottom, *p2bottom = NULL;

   stack_init (&p1top, &p1bottom);  // Initialise player 1 stack
   stack_init (&p2top, &p2bottom);  // Initialise player 2 stack

   deal (deck, &p1top, &p2top);     // Deal 26 cards to each player

   return (0);
}
[/main.c]

[main.h]
struct card {
   int value;
   char *suit;

   struct card *nextCard;
   struct card *prevCard;
};

typedef struct card card;
[/main.h]

[stack.c]
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "main.h"
#include "deck.h"
#include "stack.h"


void stack_init (card **top, card **bottom)
{
   *top = NULL;
   *bottom = NULL;
}

void push (card *new, card **top)
{
   card *prev = *top;

   new->nextCard = NULL;

   if (*top == NULL)
   {
      new->prevCard = NULL;
   }
   else
   {
      prev->nextCard = new;
      new->prevCard = prev;
   }

   *top = new;
}


void queue (card *hold, card **bottom)
{
   card *prev = *bottom;
   card *new;

   new->prevCard = NULL;

   prev->prevCard = new;
   new->nextCard = prev;

   *bottom = new;
}


card *pop (card **top)
{
   return *top;
}
[/stack.c]

[stack.h]
/* Function Prototypes */
void stack_init (card **top, card **bottom);
void push (card *new, card **top);
void queue (card *new, card **bottom);
card *pop (card **top);
[/stack.h]

[deck.c]
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "main.h"
#include "deck.h"
#include "stack.h"


card *init_card (char *suit, int value)
{
   card *newCard = (card *) malloc (sizeof(card));

   if (newCard == NULL)    // Check for successful malloc()
      return (NULL);
   else
   {
      strcpy(newCard->suit, suit);
      newCard->value = value;
      return (newCard);
   }
}

void fill_deck (card *deck, char *suit[])
{
   int i;

   for (i = 0; i < 52; i++)
   {
      deck[i].value = (i % 13) + 2;
      deck[i].suit = suit[i / 13];
   }
}

void shuffle (card *deck)
{
   srand (time(NULL));

   int i, j;
   card temp;

   for (i = 0; i < 52; i++)
   {
      j = rand() % 52;
      temp = deck[i];
      deck[i] = deck[j];
      deck[j] = temp;
   }
}

void deal (card *deck, card **p1top, card **p2top)
{
   int i;
   card *hold;

   for (i = 0; i < 52; i++)
   {
      hold = init_card (deck[i].suit, deck[i].value);

      if (i % 2 == 0)
      {
         push (hold, p1top);
      }
      else
      {
         push (hold, p2top);
      }
   }
}
[/deck.c]

[deck.h]
card *init_card (char *suit, int value);
void fill_deck(card *, char *suit[]);
void shuffle(card *);
void deal (card *, card **, card **);
[/deck.h]