Taking list as an input from Python to C


c__

Joined
Jul 21, 2022
Messages
1
Reaction score
0
Hello,

I am trying to send a list as input from python to c. But I am struggling to do that:

1)I do not know how to send list as an input
2)I also do not know how to receive this input in c:
Here is my python code:
Code:
combinations = list(itertools.product([0, 1], repeat=(6)))
for xz in combinations:
    angle_ = angle_*math.pi/180
    print("Angle_: ", angle_)
    angle=angle_
    x = subprocess.run(["./sim", str(angle_), int(xz),int(xz)], stdout=subprocess.PIPE)
    #this line is wrong. I am telling int(xz) but it is list
    print("Angle: ", angle)

And here is the main.c:

int main(int argc,char *argv[]){
//int i_xset,i_zset;
int xset[6],zset[6];
sscanf(argv[1], "%le",&angle);
sscanf(argv[2], "%i",&i_xset);
sscanf(argv[3], "%i", &i_zset);
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top