I want to pass the reference to a string from python to a c program. The c program writes something to the string and I want to read it back in python. The c program looks like:
void foo(char *name) {
name = "Hello World";
}
And the Python script:
>>> import ctypes
>>> lib=ctypes.CDLL('libfoo.so')
>>> name=ctypes.create_string_buffer(32)
>>> print name.value
>>> lib.foo(name)
>>> print name.value
>>>
I'd expect "Hello World" after the second print.
I'm sure it's simple, but I can't figure out what's wrong...