Skip to content Skip to sidebar Skip to footer

Python: Converting Strings For Use With Ctypes.c_void_p()

given a string: msg='hello world' How can I define this as a ctypes.c_void_p() data type? the following code yields a 'cannot be converted to pointer' exception: data=ctypes.c_voi

Solution 1:

Something like this? Using ctypes.cast?

>>> import ctypes
>>> p1= ctypes.c_char_p("hi mom")
>>> ctypes.cast( p1, ctypes.c_void_p )
c_void_p(11133300)

Post a Comment for "Python: Converting Strings For Use With Ctypes.c_void_p()"