【发布时间】:2011-05-07 22:37:40
【问题描述】:
如果我有以下 2 组代码,如何将它们粘合在一起?
void
c_function(void *ptr) {
int i;
for (i = 0; i < 10; i++) {
printf("%p", ptr[i]);
}
return;
}
def python_routine(y):
x = []
for e in y:
x.append(e)
如何使用 x 中的连续元素列表调用 c_function?我试图将 x 转换为 c_void_p,但这没有用。
我也尝试使用类似的东西
x = c_void_p * 10
for e in y:
x[i] = e
但这会出现语法错误。
C 代码显然需要数组的地址。我怎样才能做到这一点?
【问题讨论】: