Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Observations,</p> <p>Count_List() should count each element on list, your version only counts starting at the second item on the list. And it should always return an int,</p> <pre><code>int Count_List(Library *Head) { int count = 0; Library *Tmp = Head; if(!Tmp) return(count); while(Tmp != NULL) { count++; Tmp = Tmp-&gt;next; } return(count); } </code></pre> <p>Inside Read_File() you call Create_List(Entry,Head), but your function signature for Create_List(Head,Entry); which do you intend? Probably (Head,Entry). Use fgets and sscanf to Read_File,</p> <pre><code>Library * Read_File(FILE *fp) { Library *Head, *Entry; Head = Entry = NULL; char genre[100], band[100], album[100]; float rating; char line[100]; while(fgets(line,sizeof(line),fp) { sscanf(line,"%s %s %s %f", genre, band, album, &amp;rating); Entry = Create_Album(genre, band, album, rating); Head = Create_List(Head,Entry); } return Head; } </code></pre> <p>Looking at Create_List(), you seem to be implementing the List as a stack (push Entry onto head of list),</p> <pre><code>Library * Create_List(Library *Head, Library *Entry) { if(!Head) return Entry; Entry-&gt;next = Head; return Entry; } </code></pre> <p>Create_Album() needs to check for successful malloc before assigning values to member variables,</p> <pre><code> Library *Entry=NULL; if( !(Entry=(Library*)malloc(sizeof(Library))) ) { printf("error creating album\n");fflush(stdout); return Entry; } </code></pre> <p>Speaking of Library struct, you declare the members genre, band, album as pointers, but you need space to copy memory, example,</p> <pre><code>typedef struct library { char genre[50]; char band[50]; char album[50]; float rating; struct library *next; }Library; </code></pre> <p>My suggestion would be to build constructor and destructor functions LibraryNew, LibraryDel.</p> <p>Check for (argc&lt;2) arguments (your message says not enough, instead of need 2,</p> <pre><code> if(argc &lt; 2) { printf("Not enough arguments.\n"); return 0; } </code></pre> <p>And that fixes the biggest problems,</p> <pre><code>./library music.x 2 line:Rock Antrax Party 1.2 Rock,Antrax,Party,1.200000 Rock,Antrax,Party,1.200000 added: Rock,Antrax,Party,1.200000 Rock Antrax Party 1.20 Rock Antrax Party 1.20 Which genre would you like to delete? </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload