c言語で以下のような実行結果を出したいのですが、どのように直すべきですか? 実行結果 5 10 15 20 コード #include <stdio.h>
c言語で以下のような実行結果を出したいのですが、どのように直すべきですか? 実行結果 5 10 15 20 コード #include <stdio.h> #include <stdlib.h> typedef struct cell{ int val; struct cell *next; }CELL; void printList(CELL *list); int main(void){ CELL * top; top = (CELL *)malloc(sizeof(CELL)); top->val=5; top->next->val=10; top->next->next->val=15; top->next->next->next->val=20; printList(top); free(top); } void printList(CELL *list){ printf("%d\n",list->val); printf("%d\n",list->next->val); printf("%d\n",list->next->next->val); printf("%d\n",list->next->next->next->val); }