开发者

Find the position of a string in an array of string with the GLib

开发者 https://www.devze.com 2022-12-31 20:32 出处:网络
I have an array of string, like: char **strings = {\"str1\", \"str2\"}; And i would like to know if there is a function in the glib to find the position of a string in this array.

I have an array of string, like:

char **strings = {"str1", "str2"};

And i would like to know if there is a function in the glib to find the position of a string in this array.

I guess i could just do g_strcmp0 in a for() loop, but there ma开发者_运维技巧y be a better way to do it.

Thanks


The function you want does not exist, so you'll have to do it in a for-loop. If you used a GList instead of an array, then you could use g_list_index().

0

精彩评论

暂无评论...
验证码 换一张
取 消