54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
#include "a_train.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
|
|
/*int main(void){
|
|
printf("Zadajte zoznam cieľových staníc a počet cestujúcich.\n");
|
|
printf("Zoznam zakončite prázdnym riadkom.\n");
|
|
|
|
add_car;
|
|
return 0;
|
|
}*/
|
|
|
|
struct car* add_car(struct car* first,const char* target) {
|
|
struct car* newcar = calloc(1,sizeof(struct car));
|
|
struct car* this=first;
|
|
strcpy(newcar->value, target);
|
|
if(this==NULL){
|
|
return newcar;
|
|
}
|
|
while(this->next!=NULL){
|
|
this=this->next;
|
|
}
|
|
this->next = newcar;
|
|
return first;
|
|
}
|
|
|
|
void print_train(struct car* first) {
|
|
struct car* this=first;
|
|
while(this->next!=NULL){
|
|
printf("%c",this->value);
|
|
this=this->next;
|
|
}
|
|
}
|
|
|
|
void cancel_train(struct car* first) {
|
|
}
|
|
|
|
struct car* clear_train(struct car* first, const char* target) {
|
|
struct car* prev = first;
|
|
// Už sme si istí, že prev a prev->next nie sú NULL
|
|
// while (prev->next->next != NULL){
|
|
// prev = prev->next;
|
|
//}
|
|
//struct car* third = prev->next->next;
|
|
//free(prev->next);
|
|
//prev->next = third;
|
|
//return first;
|
|
|
|
return NULL;
|
|
}
|
|
|