struct database {
char name[25];
int age[5];
// in my opinion you should only keep dob, since age would have to be constantly updated
int dob[10];
struct database *next;
} TCel, *TList, **Alist;
的基本思路是,当你创建一个新的CEL,使用“下一个”指针,以IT连锁链表。例如,您可以在列表的末尾添加一个新的小区:
AList InsEnd(AList aL, Info e)
{
TLista aux;
// allocate cel and set the information inside it
aux = AlocCel(e);
if (!aux) return aL;
while (*aL != NULL)
aL = &(*aL)->next;
// linking the node
*aL = aux;
return aL;
}
或
TList InsEnd2(TList aL, Info e)
{
TLista aux;
aux = AlocCel(e);
if(!aux) return aL;
while(aL->next != NULL)
aL = aL->next;
// linking the node
aL->next = aux;
return aL;
}
对于'C'动态分配内存,寻找'malloc'和'免费'。 – 2011-01-05 07:24:44
是的,肯定我必须使用malloc和免费的,但我dnt knw如何创建链接列表..内链表只有我会使用malloc和免费,,,对吗? – kamakshi 2011-01-05 07:29:18
在您正在使用的入门书中查看它。请不要告诉我你正计划通过在stackoverflow上提问来学习编程。这将是一个糟糕的进行方式。 – 2011-01-05 08:08:21