Initializacia
This commit is contained in:
parent
6448cb0e4d
commit
2e25765e5d
@ -3,20 +3,22 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct car* add_car(struct car* first,const char* target) {
|
||||
struct car* add_car(struct car* first, const char* target) {
|
||||
struct car* last = first;
|
||||
struct car* newcar* = calloc(1, sizeof(struct car));
|
||||
struct car* newcar = calloc(1, sizeof(struct car));
|
||||
strcpy(newcar->value, target);
|
||||
if (last != NULL){
|
||||
|
||||
if (last != NULL) {
|
||||
struct car* current = last;
|
||||
while(current->next != NULL){
|
||||
current = current->next
|
||||
while (current->next != NULL) {
|
||||
current = current->next;
|
||||
}
|
||||
current->next = newcar;
|
||||
} else{
|
||||
} else {
|
||||
last = newcar;
|
||||
return last;
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user