Re: Memory allocation using g_malloc
- From: "Greg Suarez" <linux2512 gmail com>
- To: 3saul <saul_lethbridge hotmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Memory allocation using g_malloc
- Date: Thu, 1 Jun 2006 10:55:34 -0700
On 5/30/06, 3saul <saul_lethbridge hotmail com> wrote:
Thanks for the response. Let me elaborate a little. I have a list of files
in
a dir (without knowing how many)
a.txt
b.txt
c.txt
I want to be able to put the names of the files into an array so that I
can
refer to them later like this
array[0][0] = a.txt
array[0][1] = b.txt
and so on...Perhaps there is a better way to go about this but this seems
as
good a way as any to me.
You should probably use the GPtrArray. And as you iterate through your list
of files you can do g_ptr_array_add( my_array, g_strdup(filename) ).
To iterate through the array you do:
for( i = 0; i < my_array->len; i++ )
g_print( "%s", g_ptr_array_index(my_array, i) );
Don't forget to free the filenames stored in the GPtrArray.
--
Greg Suarez
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]