Re: GList



On Monday 02 May 2005 18:13, ÐÐÑÐÐÐÐÑÐÐ ÐÐÐÐÑ wrote:

I think that the result of next code must be 3, but
I have 0. If uncomment "l=..." it's work correctly

    GList* l=NULL;
//    l=g_list_alloc();

    g_list_append(l,GINT_TO_POINTER(1));
    g_list_append(l,GINT_TO_POINTER(1));
    g_list_append(l,GINT_TO_POINTER(1));

    printf("%i",g_list_length(l));

you need to do

 l = g_list_append (l, GINT_TO_POINTER(1));
 l = g_list_append (l, GINT_TO_POINTER(2));
 l = g_list_append (l, GINT_TO_POINTER(3));

Don't use g_list_alloc. You're very unlikely to ever need it. 

Cheers
 -Tim





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]