Тема: Не можу зрозуміти помилку в коді,компілятор знахадить її у 17 строці.
Не можу зрозуміти помилку в коді,компілятор знахадить її у 17 строці.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct Node {
    int data;
    struct Node* next;
} Node;
typedef struct List {
    Node* head;
    Node* tail;
} List;
//-----------------------------------------------------------------------------
List* push(List* list, int data) {
    Node* node = malloc (sizeof(Node));
    node->data = data;
    node->next = NULL;
    if (list->head == NULL) {
        list->head = list->tail = node;
    }
    else {
        list->tail->next = node;
        list->tail = node;
    }
    return list;
}
//-----------------------------------------------------------------------------
void print(const List* list) {
    const Node* node;
    for (node = list->head; node; node = node->next) {
        printf("%d ", node->data);
    }
    printf("\n");
}
//-----------------------------------------------------------------------------
List* shiftLeft(List* list) {
    if (list->head == list->tail) {
        return list;
    }
    Node* node = list->head;
    list->head = list->head->next;
    node->next = NULL;
    list->tail->next = node;
    list->tail = node;
    return list;
}
//-----------------------------------------------------------------------------
List* shiftRight(List* list) {
    if (list->head == list->tail) {
        return list;
    }
    Node* node;
    for (node = list->head; node->next != list->tail; node = node->next) { ; }
    node->next = NULL;
    list->tail->next = list->head;
    list->head = list->tail;
    list->tail = node;
    return list;
}
//-----------------------------------------------------------------------------
List* shiftLeftN(List* list, unsigned cnt) {
    while (cnt--) {
        shiftLeft(list);
    }
    return list;
}
//-----------------------------------------------------------------------------
List* shiftRightN(List* list, unsigned cnt) {
    while (cnt--) {
        shiftRight(list);
    }
    return list;
}
//-----------------------------------------------------------------------------
int main() {
    List list = { NULL, NULL };
    int i = 10;
    srand(time(NULL));
    while (i--) {
        push(&list, rand() % 100);
    }
    print(&list);
    print(shiftLeftN(&list, 3));
    print(shiftRightN(&list, 4));
    return 0;
}