title: Segmentation fault with strcmp in a list insertion
body: <p>I'm trying to create a list in alphabetical order (first by author, then by name). I tried to do it by comparing the two strings with <code>strcmp()</code> but I'm getting a segmentation fault. </p>
  
  <p>I'll leave the GDB run result down here and the function, it's one of the first programs I made with lists so the code has probably other errors.</p>
  
  <p>GDB run :</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.                         
  0x0000000000400c65 in insert (lPtr=0x7fffffffeb38, isbn_i=978044,            
      name_i=0x7fffffffeb40 "Suzanne Collins",                                 
      author_i=0x7fffffffeb80 "The Hunger Games") at main.c:178                
  178             while(strcmp(author_i, currPtr-&gt;author) &lt; 0){
  </code></pre>
  
  <pre><code>typedef struct library{ //struct insertion from stdin
      int isbn;
      char *author;
      char *name;
      int act; //actual books in memory
      int tot; //total books
      struct library *nextPtr; //node
  }Lib;
  
  typedef Lib *NodePtr;
  
  
  //called by a while, receives input from integers and two arrays of char
  
  void insert(NodePtr *lPtr, int isbn_i, char *name_i, char *author_i){  
  
      NodePtr newPtr = malloc(sizeof(Lib));
  
      newPtr-&gt;isbn = isbn_i;  //scanf insertion in node
      newPtr-&gt;author = author_i;
      newPtr-&gt;name = name_i;
  
      newPtr-&gt;nextPtr = NULL;
      NodePtr prevPtr = NULL;
  
      newPtr-&gt;act = 1;
      newPtr-&gt;tot = 1;
  
      if(lPtr == NULL){ //empty list
          *lPtr = newPtr;
          return;
      }
  
      NodePtr currPtr = *lPtr;
  
      while(strcmp(author_i, currPtr-&gt;author) &lt; 0){ //author is different, list slides    
          prevPtr = currPtr;
          currPtr = currPtr-&gt;nextPtr;
      }
  
      if(strcmp(author_i, currPtr-&gt;author)== 0){ //same author
  
          while(strcmp(name_i, currPtr-&gt;name) &lt; 0){ //list sliding
              prevPtr = currPtr;
              currPtr = currPtr-&gt;nextPtr;
          }
  
          if(strcmp(name_i, currPtr-&gt;name) == 0){ 
              currPtr-&gt;act += 1; //updates current counter and returns (to avoid duplicates)
              currPtr-&gt;tot += 1;
  
              free(newPtr);
              return;
          }
      }
  
      prevPtr-&gt;nextPtr = newPtr; //insertion between two nodes
      newPtr-&gt;nextPtr = currPtr;
  }
  
  
  </code></pre>