Alright, so I know that I'm supposed to use strcpy for strings, but I just can't get it to work. The program will just crash after entering the first bit of information. Here is the code I have for the insert function:
My intro teacher never went over strcpy or strcmp at all, so I really don't know how to use them.Code:void insert(struct vehicle** head, char* make, char* model, int year, char* color, char* license) { struct vehicle* newvehicle; struct vehicle* crnt = (*head); newvehicle = malloc(sizeof(struct vehicle)); newvehicle->make = make; newvehicle->model = model; newvehicle->year = year; newvehicle->color = color; newvehicle->license = license; if ((*head) == NULL || (*head)->license > license) { strcpy((*head),newvehicle->next); strcpy(newvehicle,(*head)); return; } while(crnt->next != NULL && crnt->next->license < license) { strcpy(crnt->next, crnt); } strcpy(crnt->next,newvehicle->next); strcpy(newvehicle,crnt->next); }



LinkBack URL
About LinkBacks


