title: Writing data from a linked list to a binary file using fwrite.
body: <p>I do not know how to approach this task. </p>
  
  <p>I specifically have to use fwrite, but my problem is that I do not know how to write different file types(char[], int, double) into a single line in the binary file, increment it, then write the next lot of data from the linked list increment it..... and so on.</p>
  
  <p>The code below writes data from a linked list(Data) into text file, goes to next line and repeats the process until the last element of the list has been written to the text file.</p>
  
  <p>I need to code a function that has the same principles but writes the data from the linked list into an binary file using fwrite. Any ideas guys?</p>
  
  <pre><code>void WriteTextFile(ListDataType *Data, int numEl)
  {
      FILE *textfile;
  
      char name[50];
  
      printf("\n\nWhat would you like to call the text file in which the data will be stored?\nNB remember to add \".txt\" after your chosen name!!!\nENTER NAME NOW&gt;&gt;");
      scanf("%s", name);
  
      textfile = fopen(name, "w+");
  
      do
      {
          fprintf(textfile, "%s %d %d %.2lf %.2lf %.2lf %.2lf\n", Data-&gt;component.name, Data-&gt;component.int1, Data-&gt;component.int2, Data-&gt;component.double1, Data-&gt;double2, Data-&gt;double3, Data-&gt;double4 );
          Data = Data-&gt;nextPtr;
      }while(Data != NULL);
  
      fclose(textfile);
  }
  </code></pre>