Returning an array from C code
Posted: Thu Jul 09, 2009 11:26 am
Hi all
I need to return an array (or perhaps write to an (x)Harbour array) from a C function where I have something like
char **things
I need to iterate through things like this (given that there are int num_things of things:
for ( loop_counter = 0; loop_counter < num_things; loop_counter++ )
{
// do something here to put things[loop_counter] into the array
}
for ( loop_counter = 0; loop_counter < num_things; loop_counter++ )
{
free( things[loop_counter] );
}
free( things );
// if above is building an array I would need to pass it back here
// but if above wrote to an existing (x)harbour array then there would be no work to be done here.
Can someone help please?
Thanks
I need to return an array (or perhaps write to an (x)Harbour array) from a C function where I have something like
char **things
I need to iterate through things like this (given that there are int num_things of things:
for ( loop_counter = 0; loop_counter < num_things; loop_counter++ )
{
// do something here to put things[loop_counter] into the array
}
for ( loop_counter = 0; loop_counter < num_things; loop_counter++ )
{
free( things[loop_counter] );
}
free( things );
// if above is building an array I would need to pass it back here
// but if above wrote to an existing (x)harbour array then there would be no work to be done here.
Can someone help please?
Thanks