text: Q:
  
  I am trying to write an abstract data type to represent sets of integer items using linked lists. I am getting a segmentation fault
  
  I am trying to write an abstract data type to represent sets of integer items using linked lists. I am getting a segmentation fault (linux) or program crashing (windows) and can't understand whats wrong with my code.
  #include<stdio.h>
  #include<stdlib.h>
  
  struct linkedListElement{
      int data;
      struct linkedListElement * next;
          };
  
  struct linkedListSet {
  
      struct linkedListElement * header;
      struct linkedListElement * current;
      struct linkedListElement * temp;
  
           };
  
  struct linkedListSet * createdSet (){
  
  struct linkedListSet * newSet = malloc(sizeof(struct linkedListSet));
  
  newSet->header->data = 0;
  newSet->header->next = NULL;
  
  return newSet;
  
                   };
  
  int main(){
  //create set
      struct linkedListSet * firstSet = createdSet();
  
  return (0);
  }   
  
  A:
  
  Take a look here..
  struct linkedListSet * createdSet (){
  
      struct linkedListSet * newSet = malloc(sizeof(struct linkedListSet));
  
      // newSet->header is just a pointer - doesn't point to anything valid!
      newSet->header->data = 0;
      newSet->header->next = NULL;
  
      return newSet;
  
  };
  
  You need to ensure the pointers are valid as well.  You may do something like:
  newSet->header = malloc(sizeof(struct linkedListElement));
  
  