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);
 
Joined
Aug 16, 2022
Messages
2
Reaction score
0
Are you using the API? Because it doesn't look like so...
You are reading the source. You're supposed to transfer data from the C application to Python or from the Python application to C (I'm not sure which one you're doing).
The Python API can be quite tricky though. Just, stay away from it. I've tried it and it's hard because it lacks debugging tools.
 

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

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top