我想把char指针数组传给C函数。在
我指的是http://docs.python.org/library/ctypes.html#arrays
我写下面的代码。在
from ctypes import *
names = c_char_p * 4
# A 3 times for loop will be written here.
# The last array will assign to a null pointer.
# So that C function knows where is the end of the array.
names[0] = c_char_p('hello')
我得到以下错误。在
TypeError: '_ctypes.PyCArrayType' object does not support item assignment
你知道我怎么解决这个问题吗?我想与
^{pr2}$
您所做的是创建一个数组类型,而不是实际的数组,因此基本上:
然后,您可以按照以下思路进行操作:
^{pr2}$…并继续使用
names
数组作为参数调用C函数。在相关问题 更多 >
编程相关推荐