Link to home
Start Free TrialLog in
Avatar of katjas
katjas

asked on

How to implement stringlist ???

Hi experts,

I want to implement a common stringlist.
My stringlist.h with my structire looks like:

typedef struct _stringlist {
        char    **strings;
        size_t    count;
} StringList;

Now i want to implement the following function:

StringList* stringlist_insert(StringList* list,
                              char* name)

My initializing function looks like:

StringList* stringlist_initialize()
{
    StringList *stringlist = malloc(sizeof(StringList));
    if (stringlist == NULL)
        return NULL;
   
        stringlist->count = 0;
        stringlist->strings = malloc(stringlist->sl_max*
                                     sizeof(char *));
        if (stringlist->strings == NULL)
            return NULL;
       
        return stringlist;
}


I have little problems with pointers, so can
anybody please help me , how to implement the
insert function ???????????????????????????????


Many thanks
katjas
Avatar of kotan
kotan
Flag of Malaysia image

is sl_max member of stringlist?
if then, what does it for?
is it number of string or maximum char allow in one string?
ASKER CERTIFIED SOLUTION
Avatar of kotan
kotan
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of katjas
katjas

ASKER

Wow .. it works !
Thank you