title: Declaring Int variables causes segmentation fault?
body: <p>Hey guys I'm having a really peculiar segmentation fault coming up in my program.   This program is suppose to automate the card game "war"  and so far I've been able to build two randomized half decks for both players. Which would appear to show that enqueue is working correct.  I was also able to dequeue all the values and they appeared in the correct order.  However inside main if I uncomment the integer declarations in main the program segfaults every time.  I can not for the life of me figure out how simple declarations could cause faults. Please note this is my only second assignment for using queues.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;string.h&gt;
  
  typedef struct node
  {
      int value;
      int suit;
      char*sname;
      char*txt;
      struct node *next;
  } node;
  int isempty(node *base){
      if (base==NULL)
          {return 1;}
      else
          return 0;
  }
  void printlist(node *base){
      node *current=base;                                 
      if(base==NULL)
          {
              printf("The List is empty!\n");
              return;
          }
      else
          {
              printf("Content: \n");
              int count=0;
              while(current!=NULL){
                  count++;
                  printf("%s \tof \t%s\n",current-&gt;txt,current-&gt;sname);
                  current=current-&gt;next;
              }                                                    
              printf("\nCount:%d\n",count);
          }
      }       
  char* valname(int n){                                    
      char *name;                                          
      switch(n)                                            
      {                                                    
          case 0:name="two";break;                         
          case 1:name="three";break;                      
          case 2:name="four";break;                       
          case 3:name="five";break;                        
          case 4:name="six";break;                         
          case 5:name="seven";break;                       
          case 6:name="eight";break;                       
          case 7:name="nine";break;                        
          case 8:name="ten";break;                         
          case 9:name="Jack";break;
          case 10:name="Queen";break;
          case 11:name="King";break;
          case 12:name="Ace";break;
          default:printf("Broken\n");exit(1);             
      }                                                   
      return(name);                                        
  }
  char* suitname(int n){
      char *name;
      switch(n){
          case 0:name="Hearts";break;
          case 1:name="Spades";break;
          case 2:name="Clubs";break;
          case 3:name="Diamonds";break;
          default:printf("Broken\n");exit(1);
      }
      return(name);
  }
  void enqueue(node **base,int item){
  node *nn,*current=*base;
  nn=malloc(sizeof(node));
      if(*base==NULL)
      {
          *base=nn;
      }
      else
      {
          while(current-&gt;next!=NULL){
              current=current-&gt;next;
          }
          current-&gt;next=nn;
      }
      nn-&gt;value=item;
      nn-&gt;txt=valname(item%13);
      nn-&gt;sname=suitname(item/13);
      nn-&gt;next=NULL;
  }
  int dequeue(node **base){
  node *current=*base,*temp;
      if (isempty(*base)==0){
          int giveback=current-&gt;value;
          if(current-&gt;next==NULL)
          {
              free(*base);
              *base=NULL;
          }
          else
          {
              temp=current-&gt;next;
              free(current);
              *base=temp;
          }
          return giveback;
      }else{return -1;}
  }
  void createdecks(node **deck1,node **deck2){
  int i=0;
  int thenumber=0;
  int deck[52]={0};
  for(i=0;i&lt;26;i++){
          thenumber=rand()%52;
          if(deck[thenumber]==0){
              //add to list
              enqueue(deck1,thenumber);
              deck[thenumber]=1;
          }
          else
          {
              i--;
          }
      }
  for(i=0;i&lt;26;i++){
          thenumber=rand()%52;
          if(deck[thenumber]==0){
              //add to list
              enqueue(deck2,thenumber);
              deck[thenumber]=1;
          }
          else
          {
              i--;
          }
      }
  }
  int main(void){
      node *d1,*d2,*warholder;
      //int c1=0,c2=0;                    //THIS LINE!!!!!!!!!!!
      srand(time(NULL));
      createdecks(&amp;d1,&amp;d2);
      //printlist(d1);
      //printlist(d2);
      int i=0;
      for(i=0;i&lt;26;i++)
          printf("%d ",dequeue(&amp;d1)); //return testing
      printf("\n");
      printlist(d1);
  }
  </code></pre>
  
  <p>Professor's example function</p>
  
  <pre><code>char * namenum( int num)
  {
      char * name;
      switch(num)
      {
          case 0:
              name = "zero";  break;
          case 1:
              name = "one";   break;
          case 2:
              name = "two";   break;
          case 3:
              name = "three"; break;
          case 4:
              name = "four";  break;
          case 5:
              name = "five";  break;
          case 6:
              name = "six";   break;
          case 7:
              name = "seven"; break;
          case 8:
              name = "eight"; break;
          case 9:
              name = "nine"; break;
          default:
              printf("Invalid Number generated\n");
              exit(1);
      }
      return name;
  }
  </code></pre>