refresh
This commit is contained in:
parent
812da46b6a
commit
499fc49015
@ -1,7 +1,30 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "train.h"
|
||||||
|
|
||||||
struct car* add_car (struct car* first, const char* target) {
|
struct car* add_car (struct car* first, const char* target) {
|
||||||
|
struct car* novyj_vagon = (struct car*) malloc(sizeof(struct car*)); //создаём новую строку
|
||||||
|
|
||||||
|
if (novyj_vagon == NULL) {
|
||||||
|
printf("Chyba: nepodarilo sa vytvorit novy vozen!\n");
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(novyj_vagon->value, target, SIZE - 1); //Потому что строка в C всегда должна заканчиваться нулём
|
||||||
|
novyj_vagon->value[SIZE-1] = '/0';
|
||||||
|
novyj_vagon->next = NULL;
|
||||||
|
|
||||||
|
if (first == NULL) {
|
||||||
|
return novyj_vagon;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct car* actual = first;
|
||||||
|
while (actual->next !=NULL) {
|
||||||
|
actual = actual->next;
|
||||||
|
}
|
||||||
|
aktualny->next = novy_vozen;
|
||||||
|
return fist;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +37,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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user