1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> struct Gundam { int hp; int atk; char name[100]; }; struct Human { int age; char name[100]; Gundam robot; };
struct Node { int num; Node* pointer; };
int main() {
int s0[10]; Node* head = (Node*)malloc(sizeof(Node)); Node* real_head = head; for (int i = 0; i < 10; i++) { Node* current = (Node*)malloc(sizeof(Node)); current->pointer = NULL; current->num = 0;
head->num = i; head->pointer = current; head = current; }
while (real_head->pointer != NULL) { printf("%d\n", real_head->num); real_head = real_head->pointer; } }
|