tags:

views:

45

answers:

3

I've been looking at docs but I can't seem to understand very clearly, them do you guys know of anything that would be good at teaching it.

Say I had a program,

int main() {
   return 3;
}

How do I call cprogram.exe and get the return value (not neccesarily an int, structs too). I don't have a specific project that I'm working on, just trying to learn. So on top of answering this question, some references (books or otherwise) to where I could learn continuation of this, because I know its more complicated than this; would be nice; thanks in advance.

lol sentence structure.

+1  A: 

The simplest way of doing this would be to create a dll or so (depending on your platform) then use the ctypes module to call into it. The exact method for creating the dll depends on your compiler. For ctypes see http://python.net/crew/theller/ctypes/tutorial.html

Winston Ewert
A: 

Wesley Chun has a nice chapter showing how to do it in his "Core Python Programming" book.

duffymo
A: 

The Python docs themselves may be a good place to start:

http://docs.python.org/release/2.5.2/ext/intro.html

jgritty