结构体的一些练习源代码,另外还有静态链表的使用

源代码在线查看: 静态链表.c

软件大小: 4 K
上传用户: danlong
关键词: 结构体 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*创建简单的静态链表*/
				#include 
				# include 
				struct employeeData
				{
				 int id;
				 char name[10];
				 int salary;
				 struct employeeData *next;
				 }
				main()
				{
					struct employeeData e1,e2,e3;
					struct employeeData *startPtr,*ptr;
					e1.id = 1001;strcpy(e1.name,"王浩");e1.salary = 1000;
					e2.id = 1002;strcpy(e2.name,"李勇");e2.salary = 1200;
					e3.id = 1003;strcpy(e3.name,"黄耀辉");e3.salary = 1500;
					startPtr = &e1;
					e1.next = &e2;
					e2.next = &e3;
					e3.next = NULL;
					ptr = startPtr;
					do
					{
					printf("%6d%10s%6d\n",ptr->id,ptr->name,ptr->salary);
					ptr = ptr->next;
					}while (ptr != NULL);
				}			

相关资源