title: c linked list read from txt file
body: <p>I'm pretty new in c and want to make a program that can read linked list from a txt file. For example, my file is something like</p>
  
  <pre><code>0 1 6 4 8 6 8 15 56 4 864 68
  </code></pre>
  
  <p>and I want to read the info and then try display it to user.
  This is what I have made. This gives me error that expected expression before head it writes it in main part where I declared.</p>
  
  <pre><code>A = readList(head); 
  printList(head);
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  typedef struct linkedList{
      int value;
      struct linkedList *next;
  } linkedList, head;
  
  linkedList *readList(linkedList *head)
  {
      FILE *dataFile;
      dataFile = fopen("duom.txt", "r");
      if(dataFile == NULL) {
          printf("Nepasisekė atidaryti failo\n");
      } else {
          printf("Duomenų failą pavyko atidaryti\n");
      }
      while (!feof (dataFile))
          if (head == NULL) {
              head = malloc(sizeof(linkedList));
              fscanf(dataFile, "%d", &amp;head -&gt; value);
              head -&gt; next = NULL;
          } else {
              struct linkedList *current = head;
              struct linkedList *temp = malloc(sizeof(linkedList));
              while(current -&gt; next != NULL) {
                  current = current -&gt; next;
              }
              fscanf(dataFile, "%d", &amp;temp -&gt; value);
              current -&gt; next = temp;
              temp -&gt; next = NULL;
          }
      return head;
  }
  void printList(linkedList *head)
  {
      linkedList *current = head;
      while (current != NULL) {
          printf("%d-&gt;", current -&gt; value);
          current = current -&gt; next;
      }
      printf("NULL\n");
      return;
  }
  int main()
  {
      linkedList A;
      A=readList(head);
      printList(head);
      return 0;
  }
  </code></pre>