I wrote a simple C++ program to illustrate my problem:
extern "C"{
int test(int, char*);
}
int test(int i, char* var){
if (i == 1){
strcpy(var,"hi");
}
return 1;
}
I compile this into an so. From python I call:
from ctypes import *
libso = CDLL("Debug/libctypesTest.so")
func = libso.test
func.res_type = c_int
for i in xrange(5):
charP = c_char_p('bye')
func(i,charP)
print charP.value
When I run this, my output is:
bye
hi
hi
hi
hi
I expected:
bye
hi
bye
bye
bye
What am I missing?
Thanks.