train
This commit is contained in:
parent
4759677c57
commit
120b613700
@ -8,15 +8,13 @@ struct car* add_car(struct car* first,const char* target) {
|
||||
struct car* newcar = calloc(1, sizeof(struct car));
|
||||
strcpy(newcar->value, target);
|
||||
if(first == NULL){
|
||||
first = newcar;
|
||||
return newcar;
|
||||
}
|
||||
else{
|
||||
struct car *this = first;
|
||||
while(this->next != NULL){
|
||||
this = this->next;
|
||||
}
|
||||
this->next = newcar;
|
||||
}
|
||||
return first;
|
||||
|
||||
}
|
||||
@ -24,7 +22,6 @@ struct car* add_car(struct car* first,const char* target) {
|
||||
void print_train(struct car* first) {
|
||||
struct car* this = first;
|
||||
if(first == NULL){
|
||||
printf("List is empty.");
|
||||
return;
|
||||
}
|
||||
else{
|
||||
@ -37,11 +34,12 @@ void print_train(struct car* first) {
|
||||
|
||||
|
||||
void cancel_train(struct car* first) {
|
||||
if(first != NULL){
|
||||
if(first == NULL){
|
||||
return;
|
||||
}
|
||||
cancel_train(first->next);
|
||||
free(first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct car* clear_train(struct car* first, const char* target) {
|
||||
|
Loading…
Reference in New Issue
Block a user