TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: John Grey
from: Kurt Kuzba
date: 1998-07-03 05:24:50
subject: LISTLINK.C 5/5

/*_|_|   LISTLINK.C   ( part 5 of 5 )
_|_|_|   Heavily commented example of using linked lists in C.
_|_|_|   No warrantee or guarantee is given or implied.
_|_|_|   PUBLIC DOMAIN   by Kurt Kuzba.  (7/3/1998)*/
int main(void)
{
   int line, end;
   char *testline;
   LinkedList *ll = NULL;
   ll = Init_List();
   for(line = 1; line < 20; line++)
   {
      testline = malloc(81);
      sprintf(testline, "This is line %d, at %p.\n", line, testline);
      Add_To_List(ll, testline, 0);
   }
   testline = malloc(81);
   sprintf(testline, "%s",
      "Oops!!  ...  How did THAT get in there?!\n");
   Add_To_List(ll, testline, 9);
   end = Count_List(ll);
   Set_It(ll, 1);
   for(line = 1; line <= end; line++)
   {
      printf(Get_It(ll));
      Inc_It(ll);
   }
   puts("\n");
   getch();
   Del_pList(ll, testline);
   end = Count_List(ll);
   Set_It(ll, 1);
   for(line = 1; line <= end; line++)
   {
      printf(Get_It(ll));
      Inc_It(ll);
   }
   puts("\n");
   getch();
   Del_iList(ll, 9);
   end = Count_List(ll);
   Set_It(ll, 1);
   for(line = 1; line <= end; line++)
   {
      printf(Get_It(ll));
      Inc_It(ll);
   }
   puts("\n");
   getch();
   end = Count_List(ll);
   Swap_List(ll, 1, end);
   Swap_List(ll, 2, end - 1);
   Set_It(ll, 1);
   for(line = 1; line <= end; line++)
   {
      printf(Get_It(ll));
      Inc_It(ll);
   }
   puts("\n");
   getch();
   Sort_Str_List(ll);
   Set_It(ll, 1);
   for(line = 1; line <= end; line++)
   {
      printf(Get_It(ll));
      Inc_It(ll);
   }
   puts("\n");
   getch();
   Kill_List(ll);
   return 0;
}
/*_|_|   end   LISTLINK.C   ( part 5 of 5 )   */

> ] Optimist: Says I'm not all bad when I'm not much good.......

---
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728
SEEN-BY: 639/252 670/213 218
@PATH: 154/750 222 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.