Re: g_list_find



O Lun, 2004-04-26 ás 16:52, Tim Müller escribiu:
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.


Does happen the same with GNode instead of GList when using g_node_find?

How can i find a string in a GNode of strings?

   Greetings.




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