garray beginner problem



I am trying to figure out how to use GArray containers. This gives me rubbish in the printf output. I think it relates to how I am accessing the data nce it is in the array rather than what is stored in the array. Any comments and ideas would be appreciated.

 GArray *garray;


 garray = g_array_new (FALSE, FALSE, sizeof (Machine));
 for (i = 1; i < 10000; i++){
     Machine *newMach = machine_new(i,"trd11","d11","joe");
     g_array_append_val (garray, newMach);
}


for (i = 2; i < 5000; i++){
Machine *u=&(g_array_index (garray, Machine, i));
     printf("%s\n",u->machine_name);
 }

 g_array_free (garray, TRUE);



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