I’m using GLib and C to make an application wherein I need to store a list of strings (i.e, a list of char*
). Initially, I thought I would use GList or GArray, but then it hit me that strings just are pointers, so GPtrArray might be easiest to use, and so I used it. The only issue I encountered is that I have to cast the value back to a char*
when accessing it via g_ptr_array_index
as otherwise I just get a gpointer
/void*
back. However, it despite it feeling wrong to me (I’m not particularly experienced with writing C code), it seems to work just fine.
As such, I ask, is it correct to use GPtrArray
for storing an array of strings in C?
You need to sign in to view this answers
Leave feedback about this