Question: In C Language This program's purpose is to create a singly linked-list for cars to keep track of inventory. To do this, I'm using structures,

In C Language

This program's purpose is to create a singly linked-list for cars to keep track of inventory. To do this, I'm using structures, one struct car, and one struct for list. The program gets input from the command line with car.txt file

1. Fill in the function prototypes given above main() in the starter code according to the function descriptions posted below starter code image.

Function Prototypes to fill:

void listInitializer (list_t *list, FILE *inFile); void initializeFromFile (list_t *list, FILE *inFile); car_s *newCar (FILE *inFile);

Starter Code:

In C Language This program's purpose is to create a singly linked-list

Functions needed to initialize the linked list:

for cars to keep track of inventory. To do this, I'm using

Starter Code to Copy:

typedef struct car { char type[15]; // sports car, truck, convertible etc char make[20]; char model[30]; char engine[15]; // V6, V8, V4 etc int hp; // horse power char color[25]; int length; // length of car in feet double base_price; double total_price; accessories_t extras; struct car *next; } car_s;

typedef struct list { car_s *head; car_s *tail; int size; } list_t;

void listInitializer (list_t *list, FILE *inFile); void initializeFromFile (list_t *list, FILE *inFile); car_s *newCar (FILE *inFile);

int main(int argc, char *argv) { list_t *list()=newList();

FILE* inFile = NULL; //Opening .txt file inFile = fopen(argv[1], "r");

//Error message if null or does not exist, return -1 if (inFile == NULL){ printf("Could not open file. "); return -1; // -1 indicates error }

initializeFromFile (list_t *list, FILE *inFile);

return 0; }

list_t *newList() //Creating list { list_t *point = (list_t *)malloc(sizeof(list_t));

point->head = NULL; point->tail = NULL; point->size = 0;

return point; }

car.txt

sport car,BMW,330i,V6,700,Red,13,134595.00,135945.00,1,200,0,250,450,450,0

truck,Ford,F150,V8,550,Green,13,86430.00,87630.00,0,0,250,200,500,250,0

sport car,Mercdes,sl500,V6,440,Blue,13,26895.00,27745.00,0,250,0,0,350,250,0

typedef struct car { char type [15]; // sports car, truck, convertible etc char make [20]; char model[30]; char engine [15]; // V6, V8, V4 etc int hp: // horse power char color [25]; int length; // length of car in feet double base_price; double total_price; accessories_t extras; struct car *next; } car_s; typedef struct list { car_s *head; car_s *tail; int size; } list_t; void listInitializer (list_t *list, FILE *inFile); void initializeFromFile (list_t *list, FILE *inFile); car_s *newCar (FILE *inFile); int main(int argc, char *arg) { list_t *list()=newList(); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 FILE* inFile = NULL; //Opening .txt file inFile = fopen(argv[1], "-"); //Error message if null or does not exist, return -1 if (inFile == NULL) { printf("Could not open file. "); return -1; // -1 indicates error } initializeFromFile (list_t *list, FILE *inFile); return 0; } list_t *newList() //Creating list { list_t *point = (list_t *)malloc(sizeof(list_t)); point->head NULL; point->tail = NULL; point->size = 0; return point; } typedef struct car { char type [15]; // sports car, truck, convertible etc char make [20]; char model[30]; char engine [15]; // V6, V8, V4 etc int hp: // horse power char color [25]; int length; // length of car in feet double base_price; double total_price; accessories_t extras; struct car *next; } car_s; typedef struct list { car_s *head; car_s *tail; int size; } list_t; void listInitializer (list_t *list, FILE *inFile); void initializeFromFile (list_t *list, FILE *inFile); car_s *newCar (FILE *inFile); int main(int argc, char *arg) { list_t *list()=newList(); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 FILE* inFile = NULL; //Opening .txt file inFile = fopen(argv[1], "-"); //Error message if null or does not exist, return -1 if (inFile == NULL) { printf("Could not open file. "); return -1; // -1 indicates error } initializeFromFile (list_t *list, FILE *inFile); return 0; } list_t *newList() //Creating list { list_t *point = (list_t *)malloc(sizeof(list_t)); point->head NULL; point->tail = NULL; point->size = 0; return point; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!