Re: GArray conversion

while working on my project,
i again got a problem related to this.

my array count N*2 elements

so i want a natural array of array[N][2] , how can i accomplish this?

i tried to use "nat_array = (type **)g_array_free(garr, FALSE)" but this time , it cast a 1D array to 2D array, and if accessed the 1D using 2D method it will (and is) cause segment fault.

generalized description,
if garray contained M*N
then we need an natural array of n_arr[M][N]

description of my project.
it takes input from command line $<program> x,y x,y x,y ....
i dont want it to take input the number of x,y
example: not this --> $<program> N x,y x,y x,y ....

it can be accomplished by reversing the method of storage,
storing x's & y's in different Garray and then dump the g_array_free the natural pointer to n_arra[2]
im not much interested in implementing this one.

using va_list this can accomplished , which zero as ending, to g_array_natural.

also, if i accept N , i can solve the problem easily.
i would like to take your opinions, shall i input N also.

hope you all understood what i mean. :)

On Thu, Apr 4, 2013 at 9:36 PM, Christophe Fergeau <teuf gnome org> wrote:
Hey Kuldeep,

2013/4/4 kuldeep dhaka <kuldeepdhaka9 gmail com>:
> c-code:
> GArray * arr;
> gdouble * natural_array;
> unsigned int size;
> arr = g_array_new (FALSE, FALSE, sizeof (gdouble));
> ... add values to GArray ....
> <store the size of garray in size var>
> natural_array = g_array_natural(arr, sizeof(double));

I think
natural_array = (gdouble*)g_array_free(arr, FALSE);
would do what you are asking for.


Kuldeep Singh Dhaka
SaKul Web Developers
Skype: kuldeep.dhaka
kuldeepdhaka9 gmail com
Programmer, Open Source, Web Developer, Entrepreneur, Animal Lover, Student, Blogger, Reverse Engineer, Embedded System.

Bitcoins Accepted.
My GnuPG Public Key
Fork Me

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