Returning an array from C code

Post Reply
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Returning an array from C code

Post by xProgrammer »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Returning an array from C code

Post by Antonio Linares »

Doug,

Harbour function Directory() is a great example to create and fill mutidimensional arrays from C:

http://harbour-project.svn.sourceforge. ... hrev=11679
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Re: Returning an array from C code

Post by xProgrammer »

Thanks Antonio

Code is most instructive. Should be put to good use shortly. First target will be native CUPS support. If done as a class it would presumably be TCUPS (teacups)?

Regards

Doug
Post Reply