Im doing a c assignment for college where I have to create a database like program which can store up to 100 records for make, model, etc of a car. So I have decided to use structures and linked lists. But my problem is if I can do this:
So I know that some of the bits at the prototypes aren’t here in this snippet but im getting a couple of errors with the passing in to the insert function could any one tell me where im going wrong or if I have to change the program totallyCode:#include <stdio.h> #include <stdlib.h> /* self-referential structure */ struct listNode { char data; /* each listNode contains a character */ struct listNode *nextPtr; /* pointer to next node*/ }; /* end structure listNode */ typedef struct listNode ListNode; /* synonym for struct listNode */ typedef ListNode *ListNodePtr; /* synonym for ListNode* */ struct CarData { char Make [20]; /* char entered by user */ char Model [20]; int Year; double Price; char Reg_num [12]; long int Mileage; } record[]; int i; /* prototypes */ void insert( ListNodePtr *sPtr, struct stuff[]); char delete( ListNodePtr *sPtr, char value ); int isEmpty( ListNodePtr sPtr ); void printList( ListNodePtr currentPtr ); void instructions( void ); int main() { char Cmake [20]; char Cmodel [20]; int Cyear; double Cprice; char Creg_num [12]; long int Cmileage; ListNodePtr startPtr = NULL; /* initially there are no nodes */ int choice; /* user's choice */ int item; instructions(); /* display the menu */ printf( "? " ); scanf( "%i", &choice ); /* loop while user does not choose 3 */ while ( choice != 3 ) { switch ( choice ) { case 1: printf( "Enter a Car Make "); scanf( "\n%s", & Cmake ); printf ("Enter a Car Model"); scanf ("\n%s", & Cmodel); do { printf ("Enter the Year of the Car"); scanf( "\n%s",& Cyear ); } while ( Cyear <=2005); printf( "Enter a Price of the Car"); scanf( "\nE%lf",& Cprice); printf( "Enter a Reg Number for the Car"); scanf( "\n%s",& Creg_num ); printf( "Enter a Mileage for the Car"); scanf( "\n%i",& Cmileage ); struct CarData record[i]= {Cmake, Cmodel, Cyear, Cprice, Creg_num, Cmileage}; insert( &startPtr, record[i]); /* insert item in list */ // printList( startPtr ); break; case 2: /* if list is not empty */ if ( !isEmpty( startPtr ) ) { printf( "Enter character to be deleted: " ); scanf( "\n%c", &item ); /* if character is found, remove it */ if ( delete( &startPtr, item ) ) { /* remove item */ printf( "%c deleted.\n", item ); // printList( startPtr ); } /* end if */ else { printf( "%c not found.\n\n", item ); } /* end else */ } /* end if */ else { printf( "List is empty.\n\n" ); } /* end else */ break; default: printf( "Invalid choice.\n\n" ); instructions(); break; } /* end switch */ printf( "? " ); scanf( "%i", &choice ); } /* end while */ printf( "End of run.\n" ); return 0; /* indicates successful termination */ } /* end main */ /* Insert a new value into the list in sorted order */ void insert( ListNodePtr *sPtr, struct stuff[]) { ListNodePtr newPtr; /* pointer to new node */ ListNodePtr previousPtr; /* pointer to previous node in list */ ListNodePtr currentPtr; /* pointer to current node in list */ newPtr = malloc( sizeof( ListNode ) ); /* create node */ if ( newPtr != NULL ) { /* is space available */ newPtr->data[i] = stuff[i]; /* place value in node */ newPtr->nextPtr = NULL; /* node does not link to another node */ previousPtr = NULL; currentPtr = *sPtr; /* loop to find the correct location in the list */ while ( currentPtr != NULL && stuff > currentPtr->data ) { previousPtr = currentPtr; /* walk to ... */ currentPtr = currentPtr->nextPtr; /* ... next node */ } /* end while */ /* insert new node at beginning of list */ if ( previousPtr == NULL ) { newPtr->nextPtr = *sPtr; *sPtr = newPtr; } /* end if */ else { /* insert new node between previousPtr and currentPtr */ previousPtr->nextPtr = newPtr; newPtr->nextPtr = currentPtr; } /* end else */ } /* end if */ else { printf( "Records not inserted. No memory available.\n"); } /* end else */ } /* end function insert */