title: Map Array in C - Linked List w/ Key: Value
body: <p>Ok my issue is when I write the node it just overwrites the head node, so when you call map_get you only get one node with data.  I want to hand the data on the head or push the head node and hang it front either works, whatever one is the easiest would be best thanks for your help.</p>
  
  <pre><code>#include &lt;assert.h&gt;
  #include&lt;stdlib.h&gt;
  #include "map.h"
  #include &lt;string.h&gt;
  int main(){
  map_t* newList = malloc(sizeof(map_t));
  map_init(newList);
  const char* passString ="a";
  const char* secondString="2";
  map_put(newList,"3","3");
  map_put(newList,"7","34");
  map_put(newList,"a","45");
  map_put(newList,passString,secondString);
  map_get(newList,secondString);
  }
  
  void map_init(map_t* self) {
  map_entry_t* newNode= malloc(sizeof(map_entry_t)); // allocate
  self-&gt;size = 0;
  self-&gt;entry = newNode; // link next
  }
  
  int map_put(map_t* self, const char* key, const char* val) {
    assert(self != NULL);
  map_entry_t* current;
  //current = self-&gt;entry-&gt;key;
  while(current-&gt;next != NULL){
      current = current-&gt;next;
  
  }
  self-&gt;entry-&gt;key = key;
  self-&gt;entry-&gt;value = val;
  map_entry_t* newNode = malloc(sizeof(map_entry_t));
  
  
  printf("\ntry printing the list \n");
  printf(self-&gt;entry-&gt;key);
  printf(" :was the key and the value is \n");
  printf(self-&gt;entry-&gt;value);
  printf("\n");
  
  
  }
  
  const char* map_get(map_t* self, const char* key) {
    assert(self != NULL);
  const char* target = key;
  int i=0;
  for(i; i&lt;=self-&gt;size; i++) 
  {
  printf("\n\ninside the list\n");
  printf(self-&gt;entry-&gt;value);
  printf("\n");
  }
  }
  
  int map_size(map_t* self) {
    assert(self != NULL);
  
  }
  
  int map_remove(map_t* self, const char* key) {
    assert(self != NULL);
  
  }
  
  int map_serialize(map_t* self, FILE* stream) {
    assert(self != NULL);
  
  }
  
  int map_deserialize(map_t* self, FILE* stream) {
    assert(self != NULL);
  
  }
  
  void map_destroy(map_t* self) {
    assert(self != NULL);
  
  }
  
  
  map.h
  
      #ifndef __A1_MAP_H__
  #define __A1_MAP_H__
  
  #include &lt;stdio.h&gt;
  
  #define SYS_ERROR -1
  #define OK 0
  #define KEY_EXISTS 1
  #define NO_KEY_EXISTS 2
  
  // Strange type definition due to the recursive nature
  //   of the struct. This technique is called 'forward
  //   declaration' and is necessary for compilation reasons.
  typedef struct _map_entry map_entry_t;
  struct _map_entry {
    char* key;
    char* value;
    map_entry_t* next;
  } ;
  
  typedef struct _map {
    map_entry_t* entry;
    int size;
  } map_t;
  
  // Part one functions.
  void map_init(map_t*);
  int map_put(map_t*, const char*, const char*);
  const char* map_get(map_t*, const char*);
  int map_remove(map_t*, const char*);
  int map_size(map_t*);
  void map_destroy(map_t*);
  
  // Part two functions. 
  int map_serialize(map_t*, FILE*);
  int map_deserialize(map_t*, FILE*);
  
  #endif
  </code></pre>