代码如下:
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char id[300];
char password[300];
}Elemtype;
struct LNode
{
Elemtype data;
struct LNode *next;
};
int main(int argc, char *argv[])
{
struct LNode boy;
strcpy(boy.data.id,"password");
strcpy(boy.data.password,"1");
struct LNode boy2;
strcpy(boy2.data.id,"password2");
strcpy(boy2.data.password,"2");
struct LNode boy3;
strcpy(boy3.data.id,"password3");
strcpy(boy3.data.password,"3");
struct LNode boy4;
strcpy(boy4.data.id,"password4");
strcpy(boy4.data.password,"4");
boy.next=&boy2;
boy2.next=&boy3;
boy3.next=&boy4;
boy4.next=&boy;
struct LNode *boy5;
boy5=&boy;
int a;
for(a=0;a<8;a++)
{
printf("%s\t%s\n",boy5->data.id,boy5->data.password);
boy5=boy5->next;
}
system("pause");
return 0;
}
程序运行结果如下:
?
|