0
以下是C函數para_trans_test。如何使用ctypes將字符串數組從python傳遞到C並修改C中的數組值
void para_trans_test(char x [] [100])
{
strncpy(x[0],"zzz",100);
}
以下是不起作用的python代碼。
lib.para_trans_test.argtypes= [ctypes.POINTER(ctypes.c_char_p)]
numParams=2
L=numpy.array(['xxx','yyy'])
print(type(L))
py_s1 = (ctypes.c_char_p * numParams)()
py_s1[:]=L
print("py_s1=",py_s1)
lib.para_trans_test(py_s1)
print(py_s1)
最初數組L是('xxx','yyy')。
調用C函數para_trans_test我想排列L是( 'ZZZ', 'YYY')
不工作*如何* ? –