标签:ima logs .com ring 简单 sizeof turn img ges
#include <stdlib.h> #include <string.h> #include <stdio.h> #pragma warning(disable:4996) typedef struct _Teacher { char name[64]; int age; struct _Teacher *next; }Teacher; int main() { Teacher t1, t2, t3; memset(&t1,0,sizeof(Teacher)); memset(&t2, 0, sizeof(Teacher)); memset(&t3, 0, sizeof(Teacher)); t1.next = &t2; t2.next = &t3; t3.next = NULL; t1.age = 20; t2.age = 30; t3.age = 40; Teacher *p = &t1; // 分别打印t1,t2,t3 while (p) { printf("年龄为:%d\n",p->age); p = p->next; } system("pause"); return 0; }
输出:
标签:ima logs .com ring 简单 sizeof turn img ges
原文地址:http://www.cnblogs.com/yongdaimi/p/6953427.html