title: How to create a linked list from a binary input file? With first few bytes being an int and the next few a char and so on
body: <p>I want to create a linked list from an input binary file.  The first sizeof(int) bytes is an int and the next sizeof(char) bytes is a char and it keeps going like that. 
  What I want to do is create a linked list from this file where each node in the linked list contains a character and a tree node that contains this int value.</p>
  
  <p>I am stuck when it comes to creating a linked list out of this file. If it was just a regular file with ints and no binary and no chars, I would have used fscanf to read the file and stored its contents into an array, and then I would have traversed through the array and made the nodes. However, I am confused when these chars are present in the file. Could anyone please help me and tell me if there is a way to create a linked list?</p>
  
  <p>Edits -></p>
  
  <pre><code>ListNode *head = malloc(sizeof(ListNode)*sizeoffile);
  
  //how do i find the size of the file.
  //if it was a file with just integers, I would have done something like this
  // int value;
  // int count = 0;
  //while(fscanf(fptr, "%d", &amp;value)==1)
  //{
  //  count++;
  //}
  //But now that there is chars, I am really confused how I would determine  
  //the size of the file.
  
  while(!feof(fptr))
  {
    fread(head, sizeof(int)+sizeof(char), 1, fptr);
  }
  
  I know this is not right. ^
  </code></pre>