add
This commit is contained in:
parent
d8021186e1
commit
8afedc84ac
@ -7,9 +7,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){
|
||||
return newcar;
|
||||
}
|
||||
if(first->next == NULL){
|
||||
first->next = newcar;
|
||||
}
|
||||
struct car *this = first;
|
||||
while(this->next != NULL){
|
||||
this = this->next;
|
||||
@ -36,6 +40,7 @@ void cancel_train(struct car* first) {
|
||||
exit(0);
|
||||
}
|
||||
if(first->next == NULL){
|
||||
printf("Tam je null");
|
||||
struct car* this = first;
|
||||
first = first->next;
|
||||
free(this);
|
||||
|
Loading…
Reference in New Issue
Block a user