【发布时间】:2013-12-27 18:45:36
【问题描述】:
所以我的python程序是
from ctypes import *
import ctypes
number = [0,1,2]
testlib = cdll.LoadLibrary("./a.out")
testlib.init.argtypes = [ctypes.c_int]
testlib.init.restype = ctypes.c_double
#create an array of size 3
testlib.init(3)
#Loop to fill the array
#use AccessArray to preform an action on the array
而C部分是
#include <stdio.h>
double init(int size){
double points[size];
return points[0];
}
double fillarray(double value, double location){
// i need to access
}
double AccessArray(double value, double location){
// i need to acess the array that is filled in the previous function
}
所以我需要做的是将一个数组从 python 部分传递给 C 函数,以某种方式将该数组在 C 中移动到另一个函数,我将在其中访问它以便处理它。
我被困住了,因为我想不出一种方法来移动 C 部分中的数组。
谁能教我怎么做?
【问题讨论】: