Using the CFFI library for Python, I'm trying to coax a Python string into a char*, so that I can pass it to a C function that accepts char*. I can't seem to figure out what the right incantation is.
Consider this example:
>>> from cffi import FFI
>>> ffi = FFI()
>>> ffi.new("char[]", "bob")
The result is:
TypeError: initializer for ctype 'char[]' must be a bytes or list or tuple, not str
The following does not work either:
>>> ffi.new("char*", "bob")
It says:
TypeError: initializer for ctype 'char' must be a bytes of length 1, not str