title: How do I fix abort 6 error? What does this mean? (in c language)
body: <p>This is my code below in C. I am attempting to read from <code>file.txt</code> with 2 columns: artist id and artist name, which are separated by a tab character.</p>
  
  <p>Using structs to manipulate a linked list is the idea. It's fine when I use <code>gcc -o</code>.  When I run <code>./</code>, then I get <code>abort 6</code>.    </p>
  
  <pre><code>struct artist
  {
      int artist_id;
      int altartist_id;
      int playcount;
      struct artist *next;
      char artistname[lenName];
  
  };
  
      struct artist *read_artists(char *fname)
          {
              int maxlen = 225;
  
              int artid = 0;
              int altartid = 0;
              int pc = 0;
              char artname;
  
              char data[maxlen];
              int valid = 0; // 0 acts as true 1 acts as false
              int checkresult = 0; //checks result of sscanf
  
  
  
              FILE *fp = fopen(fname ,"r");
  
              struct artist *temphead = create_artist(0,0,0,"0");
              print_artist(temphead);
  
              while (fgets(data,maxlen,fp))
              {
                  checkresult = sscanf(data,"%d\t%[^\t\n]\n",&amp;artid,&amp;artname);
  
                  if (checkresult == 2)
                  {
                      struct artist *b = NULL;
                      b = create_artist(artid,altartid,pc,&amp;artname);
  
                      temphead = add_artist(temphead,b);
                  }
                  else
                  {   printf("break out of loop valid = 1\n");
                      valid = 1; // acts as boolean variable
                      break; //breaks out of the while(fgets)
                  }
              }
  
              fclose(fp);
  
              return (temphead);
          }
  </code></pre>
  
  <p><strong>added upon request</strong></p>
  
  <pre><code>struct artist *create_artist(int artistid,int altartistid,int playcount,char *artistname)
  {
      struct artist *a = NULL;
      a = ((struct artist *)malloc(sizeof(struct artist)));
  
      if (a != NULL)
      {
          a-&gt;artist_id = artistid;
          a-&gt;altartist_id = altartistid;
          a-&gt;playcount = playcount;
          strcpy(a-&gt;artistname,artistname);
          a-&gt;next = NULL;
  
      }
  
      return (a);
  }
  </code></pre>