logo       

String Arrays: msg#00120

programming.swig

Subject: String Arrays

Hi,

I'm pretty new to using SWIG and I'm trying to write an interface to a C
program from Python. At the moment, the C program dumps strings to a file
but I would like an array of strings to be returned to Python (I guess this
would then be a list from the Python side).

At the moment I'm not sure how to go about this. The section on String
Arrays seemed to be missing from the SWIG manual. I read the typemaps
section but haven't made much progess. Does anyone know how to go about
this, or if typemaps are the way to proceed.

Out of interest, the C code I'm using for testing is as follows:

#include <stdio.h>

char (*test (void))[33]
{
static char output[2][33];

sprintf (output[0], "Test");
sprintf (output[1], "More");

return (&output[0]);
}

In Python I do the following:
>> import test
>> print test.test()
_d8d10010_p_a_33__char

Any help is much appreciated.

Regards,

Alastair.

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise