- 论坛徽章:
- 0
|
-
- #include "stdlib.h"
- #include "alloc.h"
- #include "stdio.h"
- #include "string.h"
- struct address
- {
- char name[30];
- char street[40];
- char city[20];
- char state[10];
- char zip[6];
- struct address *next;
- }list_entry;
- void inputs(char *,char *,int);
- void dls_store(struct address*);
- main()
- {
- struct address *info;
- int i;
- for(i=0;i<5;i++)
- {
- info=(struct address *)malloc(sizeof(list_entry));
- inputs("enter name:",info->name,30);
- inputs("enter street:",info->street,40);
- inputs("enter city:",info->city,20);
- inputs("enter state:",info->state,10);
- inputs("enter zip:",info->zip,6);
- dls_store(info);
- }
- }
- void inputs(char *prompt,char *s,int count)
- {
- char p[255];
- do
- {
- printf(prompt);
- gets(p);
- if(strlen(p)>count) printf("\n too long \n");
- }
- while(strlen(p)>count);
- strcpy(s,p);
- }
- void dls_store(struct address *in)
- {
- static struct address *last=NULL;
- if(!last) last=in;
- else last->next=in;
- in->next=NULL;
- last=in;
- }
复制代码
================================
不明白的在 dls_store()这个函数,
它怎么实现 next 这玩意?
还有这next具体是怎么个指向法,
望大侠们指教 |
|