- #include <iostream>
- using namespace std;
- struct student
- {
- char name[30];
- int age;
- struct student *next;
- };
- int main()
- {
- struct student st1, st2, *head, *p;
- strcpy(st1.name, "张三");
- st1.age = 20;
- strcpy(st2.name, "李四");
- st2.age = 22;
- head = &st1;
- st1.next = &st2;
- st2.next = NULL;
- p = head;
- printf("%8s%10s/n", "Name", "Age");
- while(p != NULL)
- {
- printf("%8s%10d/n", p ->name, p ->age);
- p = p ->next;
- }
- system("pause");
- return 0;
- }
开发平台 vs 2005
,运行截图