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 4/5

/*_|_|   LISTLINK.C   ( part 4 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 Sort_Str_List(LinkedList *LL)
{
   int outer, inner, item, limit = ((ListData*)LL->item)->items;
   char **Ptr_list = malloc(sizeof(char*) * limit);
   if(!Ptr_list)
      return 1;
   Set_It(LL, 1);
   for(item = 0; item < limit; item++)
   {
      Ptr_list[item] = Get_It(LL);
      Inc_It(LL);
   }
   for(outer = 0; outer < limit; outer++)
   {
      char *keep = Ptr_list[outer];
      for(inner = outer + 1; inner < limit; inner++)
         if(strcmp(keep, Ptr_list[inner]) > 0)
         {
            keep = Ptr_list[inner];
            item = inner;
         }
      if(keep != Ptr_list[outer])
      {
         Ptr_list[item] = Ptr_list[outer];
         Ptr_list[outer] = keep;
      }
   }
   Set_It(LL, 1);
   for(item = 0; item < limit; item++)
   {
      Know_It(LL)->item = Ptr_list[item];
      Inc_It(LL);
   }
   free(Ptr_list);
   return 0;
}
/*_|_|   end   LISTLINK.C   ( part 4 of 5 )   */

> ] Once you know me better, you'll like me even less...........

---
* 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™.