结构体的一些练习源代码,另外还有静态链表的使用
源代码在线查看: 静态链表.c
/*创建简单的静态链表*/
#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);
}