#include "SutList.h"
void* SutAddNList(pSutList p, int n, void* item);
SutList
. Returns NULL if passed a NULL p
value. Returns NULL, if n
is less than 0 or greater than the number of items in the list.
SutAddNList
adds an item to a specified position of a SutList
. Returns the item added to the SutList
. Returns NULL if passed a NULL p
value. Returns NULL, if n
is less than 0 or greater than the number of items in the list. The position parameter is 0 based. The SutList structure and related functions manage a dynamically sized array of void pointers which can be used as a generic container for C/C++ programmers.
#include "SutList.h"
#include <stdio.h>
pSutList list;
int i, size;
char *str;
char* str1 = "Hello";
char* str2 = "World";
list = SutNewList();
SutAddNList(list, 0, str1);
SutAddNList(list, 1, str2);
size = SutSizList(list);
for (i=0; i<size; i++)
{
str = (char*) SutGetNList(list, i);
fprintf(stderr, "%s\n", str);
}
SutDeleteList(list);