second commit

This commit is contained in:
Valér Jakubčo 2021-11-04 20:12:23 +01:00
parent e974217b7d
commit 7d8b479f1c

View File

@ -1,8 +1,10 @@
#include "a_train.h" #include "a_train.h"
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct car* add_car(struct car* first,const char* target) { struct car* add_car(struct car* first,const char* target) {
strucr car* new_car = (struct car*)calloc(1,sizeof(struct car)); struct car* new_car = (struct car*)calloc(1,sizeof(struct car));
strcpy(new_car->value, target); strcpy(new_car->value, target);
new_car->next = NULL; new_car->next = NULL;
if (first == NULL){ if (first == NULL){
@ -39,7 +41,7 @@ void cancel_train(struct car* first) {
struct car* clear_train(struct car* first, const char* target) { struct car* clear_train(struct car* first, const char* target) {
struct car* this = first; struct car* this = first;
while( this->next->next != NULL){ while( this->next->next != NULL){
if(strcmp(this->next->value, target, SIZE) == 0){ if(strcmp(this->value, target) == 0){
this->next == this->next->next; this->next == this->next->next;
free(this); free(this);
} }