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* add_car(struct car* first,const char* target) {
|
||||||
struct car* newcar = calloc(1, sizeof(struct car));
|
struct car* newcar = calloc(1, sizeof(struct car));
|
||||||
strcpy(newcar->value, target);
|
strcpy(newcar->value, target);
|
||||||
|
|
||||||
if(first == NULL){
|
if(first == NULL){
|
||||||
return newcar;
|
return newcar;
|
||||||
}
|
}
|
||||||
|
if(first->next == NULL){
|
||||||
|
first->next = newcar;
|
||||||
|
}
|
||||||
struct car *this = first;
|
struct car *this = first;
|
||||||
while(this->next != NULL){
|
while(this->next != NULL){
|
||||||
this = this->next;
|
this = this->next;
|
||||||
@ -36,6 +40,7 @@ void cancel_train(struct car* first) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if(first->next == NULL){
|
if(first->next == NULL){
|
||||||
|
printf("Tam je null");
|
||||||
struct car* this = first;
|
struct car* this = first;
|
||||||
first = first->next;
|
first = first->next;
|
||||||
free(this);
|
free(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user