title: Set the number of linked list nodes C
body: <p>I have a trace text file with several numbers written on it.
  I want to set the number of output nodes to 100, 500, or 1000.
  I want to measure the hit rate of the implemented FiFO page replacement algorithm using the given trace file.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  struct list {
      char *string;
      struct list *next;
  };
  
  typedef struct list LIST;
  
  int main(void) {
      FILE *fp;
      char line[128];
      LIST *current, *head;
  
      head = current = NULL;
      fp = fopen(&quot;test.txt&quot;, &quot;r&quot;);
  
      while(fgets(line, sizeof(line), fp)){
          LIST *node = malloc(sizeof(LIST));
          node-&gt;string = strdup(line);//note : strdup is not standard function
          node-&gt;next =NULL;
  
          if(head == NULL){
              current = head = node;
          } else {
              current = current-&gt;next = node;
          }
      }
      fclose(fp);
      //test print
      for(current = head; current ; current=current-&gt;next){
          printf(&quot;%s&quot;, current-&gt;string);
      }
      //need free for each node
      return 0;
  }
  </code></pre>