Re: g_list_find



On Monday 26 April 2004 15:25, Johnny wrote:

I have to find in a GList a string,can g_list_find do it?

g_list_find() will only work if you know the exact pointer value of the string 
you inserted into the list, it will not check whether the contents, ie. the 
strings itself, are the same (so it's most likely not what you want).

GList *node;

node = g_list_find_custom (list, 
                                          "Find this", 
                                          (GCompareFunc) strcmp);

  or

node = g_list_find_custom (list, 
                                          "Find this",
                                          (GCompareFunc) g_ascii_strcasecmp);
should do the trick.

Cheers
-Tim




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