campo-sirio/cb5/list1.c
alex a0f5e0898b This commit was generated by cvs2svn to compensate for changes in r975,
which included commits to RCS files with non-trunk default branches.

git-svn-id: svn://10.65.10.50/trunk@976 c028cbd2-c16b-5b4b-a496-9718f37d4682
1995-02-06 15:33:45 +00:00

64 lines
1.3 KiB
C
Executable File

/***********************************************************************\
* *
* LIST1.C Copyright (C) 1993 Sequiter Software Inc. *
* *
\***********************************************************************/
/* See User's Manual, page 163 */
#include "d4all.h"
#ifdef __TURBOC__
extern unsigned _stklen = 10000;
#endif
typedef struct
{
LINK4 link;
int age;
}AGES;
void print_list(LIST4 *);
void main()
{
LIST4 age_list;
AGES first_age,middle_age,last_age;
memset(&age_list,0,sizeof(age_list));
first_age.age = 3;
middle_age.age = 5;
last_age.age = 7;
l4add(&age_list,&middle_age);
l4add_before(&age_list,&middle_age,&first_age);
l4add_after(&age_list,&middle_age,&last_age);
print_list(&age_list);
l4remove(&age_list,(void *) &middle_age);
print_list(&age_list);
l4pop(&age_list);
print_list(&age_list);
}
void print_list(LIST4 *list)
{
AGES *age_ptr;
printf("\nThere are %d links\n",list->n_link);
age_ptr =(AGES *) l4first(list);
while(age_ptr != NULL)
{
printf("%d\n",age_ptr->age);
age_ptr = (AGES *) l4next(list,age_ptr);
}
age_ptr = (AGES *) list->selected;
}