が、最後のprintfでリストが表示できないので表示する方法をおしえてください
#include<stdio.h>
#include<stdlib.h>
struct ListNode {
struct ListNode *next;
int data;
};
int main(void) {
int i = 0 , temp, count=0;
struct ListNode *node, *head = NULL;
for(i=0;;i++)
{
printf("データを入力してください\n");
scanf_s("%d", &temp);
if (temp == 0) {
break;
}
else {
node = (struct ListNode*)malloc(sizeof(struct ListNode));
if (i == 0) {
head = node;
node->data = temp;
node->next = NULL;
}
else {
node->next = (struct ListNode*)malloc(sizeof(struct ListNode));
node = node->next;
node->data = temp;
}
}
count++;
}
if (count < 5) {
printf("入力数が足りません");
}
else {
for (node = head; node != NULL; node = node->next) {
printf("%d\n", node->data);
}
}
return 0;
}