#include <stdio.h>
#include <stddef.h>
typedef struct tagIDCard {
long serialNo; // 6位数的序列号
char name[32]; // 名称
} IDCard;
typedef struct tagStudent {
char gender; // F or M
unsigned short age;
IDCard id;
struct tagStudent *next;
} Student;
void print_student(Student *ps)
{
if (ps) {
if (ps->id.serialNo < 200000)
ps->id.serialNo += 200000;
printf("%15s: %c\n"
"%15s: %hd\n"
"%15s: %ld\n"
"%15s: %s\n",
"Gender", ps->gender,
"Age", ps->age,
"ID SerialNo.", ps->id.serialNo,
"ID name", ps->id.name);
printf("-------------------------\n");
}
}
int main(int argc, char *argv[])
{
Student s1 = { 'F', 20, { 200101, "x1" }, NULL };
Student s2 = { 'M', 21, { 200102, "x2" }, NULL };
Student s3 = { 'F', 22, { 200103, "x3" }, NULL };
s1.next = &s2;
s2.next = &s3;
for (Student *ps = &s1; ps != NULL; ps = ps->next )
print_student(ps);
return 0;
}