/* * プログラミング演習 第 9 回 * [例題 1] * (C) 2006 Hirohisa AMAN */ #include /* 構造体 node の宣言 */ struct node { int data; struct node* next; }; int main(void){ struct node sample[3]; struct node* head; struct node* p; /* 各データを格納 */ sample[0].data = 2; sample[1].data = 3; sample[2].data = 5; /* 各ノードを連結 */ head = &sample[0]; sample[0].next = &sample[1]; sample[1].next = &sample[2]; sample[2].next = NULL; /* リストの内容を表示 */ p = head; while ( p != NULL ){ printf("%d ", p->data); p = p->next; } printf("\n"); return 0; }