/* * ====================================================================== * Build and manipulate oneway linked list of numbers. * * Copyright (C) 1993-96 by Mark Austin and David Mazzoni. * * This software is provided "as is" without express or implied warranty. * Permission is granted to use this software on any computer system, * and to redistribute it freely, subject to the following restrictions: * * 1. The authors are not responsible for the consequences of use of * this software, even if they arise from defects in the software. * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * 4. This notice is to remain intact. * * Written by: M.A. Austin March, 1993 * ====================================================================== */ #include "miscellaneous.h" #include "numlist.h" #include int main( void ) { NUMLIST *spList; /* [a] : Add first item to list */ spList = listAddItem((NUMLIST *) NULL, 1.0 ); listPrint( "Add Item 1.0 to List", spList ); /* [b] : Append 2nd item to tail of list */ spList = listAddItem( spList, 2.0 ); listPrint( "Add Item 2.0 to List", spList ); /* [c] : Append 3rd item to tail of list */ spList = listAddItem( spList, 4.0 ); listPrint( "Add Item 4.0 to List", spList ); /* [d] : Insert 4th item into middle of list */ spList = listAddItem( spList, 3.0 ); listPrint( "Insert 3.0 into middle of List", spList ); /* [e] : Try to add duplicate list item */ spList = listAddItem( spList, 2.0); listPrint( "Try to Add Another 2.0 into List", spList ); /* [f] : Delete items 2.0, 1.0, 4.0 and 3.0 from list */ spList = listDeleteItem( spList, 2.0 ); listPrint( "Delete 2.0 from List", spList ); spList = listDeleteItem( spList, 1.0 ); listPrint( "Delete 1.0 from List", spList ); spList = listDeleteItem( spList, 4.0 ); listPrint( "Delete 4.0 from List", spList ); spList = listDeleteItem( spList, 3.0 ); listPrint( "Delete 3.0 from List", spList ); /* [g] : Free memory in list */ listFree( spList ); }