title: How to add objects to singly linked list
body: <p>Information from the file is being read into the Car struct "newcar".  I need to use the "sll_add" function below to add that information to the single liked list of type Carlist i named "list".  I'm just having trouble understanding how it all starts. Thank you for any help. </p>
  
  <pre><code>int main (void)//main function
  { 
  
  FILE *fp;//file pointer
  fp = fopen("car_inventory.txt", "r");//opens the car inventory data within the program.
  int num=0;//vairable created to keep track of the information.
  int year;//, choice;//variables use for user input.
  char str1[100];//string created to ensure the program reads the information from the original file correctly. 
  Carlist list;//creates a string of type "Car" named file to hold up to 100 cars. 
  Car newcar;//Car variable to store the info from the file. 
  
  list *last=num;
  
  if (fp)
      {
          {                   
          while(!feof(fp))//takes input from the data file.
              {
          fgets(str1,50, fp);
          sscanf(str1,"%d %s %[^\n]s", &amp;newcar.year, newcar.make, newcar.model);
  
          fgets(str1,50, fp);
          sscanf(str1,"%[^\n]s", newcar.style);
  
          fgets(str1,50, fp);
          sscanf(str1,"%[^\n]s", newcar.color);
  
          fgets(str1,50, fp);
          sscanf(str1,"%s", newcar.mileage);
  
          fgets(str1,50, fp);
          sscanf(str1,"%c", &amp;newcar.air_condition);
  
          fgets(str1,50, fp);
          sscanf(str1,"%s", newcar.inventory_num);
  
          fgets(str1,50, fp);
          sscanf(str1,"%lf", &amp;(newcar).price);
  
          fgets(str1,50, fp);
          sscanf(str1,"%[^\n]s", newcar.previous_owner);
  
          fgets(str1,50,fp);
  
  
          num++;
          sll_add(*newcar, &amp;list);
              }
          }
  
  return 0;
  
  
  #define MAX_CARS     100
  
  /* Type definitions */
  
  typedef struct car
  {
      int year;
      char make[25];
      char model[25];
      char style[25];
      char color[20];
      char mileage[8];
      char air_condition;
      char inventory_num[16];
      double price;
      char previous_owner[30];
      struct car *next;
  
  } Car;
  
  
  typedef struct carlist
  {
      Car *first;
      Car *last;
  } Carlist;
  
  
  void sll_init(Carlist *l);
  Car *sll_first(Carlist *l);
  Car *sll_end(Carlist *l);
  Car *sll_next(Car *current, Carlist *l);
  Car *sll_retrieve(Car *element, Carlist *l);
  void sll_delete(Car *c, Carlist *l);
  void sll_delete_year(Carlist *l, int year);
  void sll_add(Car *newcar, Carlist *l);
  
  
      #endif
  </code></pre>